ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-11-20 06:30:46
Exec Total Coverage
Lines: 9624 13272 72.5%
Functions: 114 142 80.3%
Branches: 7335 12403 59.1%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 439 std::map<int32_t, script_slot_data > ffcmap;
92 439 std::map<int32_t, script_slot_data > globalmap;
93 439 std::map<int32_t, script_slot_data > genericmap;
94 439 std::map<int32_t, script_slot_data > itemmap;
95 439 std::map<int32_t, script_slot_data > npcmap;
96 439 std::map<int32_t, script_slot_data > ewpnmap;
97 439 std::map<int32_t, script_slot_data > lwpnmap;
98 439 std::map<int32_t, script_slot_data > playermap;
99 439 std::map<int32_t, script_slot_data > dmapmap;
100 439 std::map<int32_t, script_slot_data > screenmap;
101 439 std::map<int32_t, script_slot_data > itemspritemap;
102 439 std::map<int32_t, script_slot_data > comboscriptmap;
103 439 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14978 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14978 return p_igetw(&unused, f);
121 }
122
123 22008 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 22001 times.
22008 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 7 output = fmt::format("{} --{}", slotname, scriptname);
129 7 break;
130 22001 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 22001 output = fmt::format("{} {}", slotname, scriptname);
133 22001 }
134 22008 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 824 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 824 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 492 times.
824 if (unencrypted_result.decoded_pf)
721 332 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 492 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 492 bool compressed = unencrypted_result.compressed;
737 492 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 492 temp_name(tmpfilename);
741 char percent_done[30];
742 492 int32_t current_method=0;
743
744 PACKFILE *f;
745 492 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 492 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(strcmp(filename, "default.qst")!=0)
752 {
753 492 box_out(filename);
754 492 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 492 box_out("...");
760 492 box_eol();
761 492 box_eol();
762
763
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(encrypted)
764 {
765 492 box_out("Decrypting...");
766 492 box_save_x();
767 492 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 63 times.
492 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 492 box_out("okay.");
833 492 box_eol();
834 492 }
835 else
836 {
837 oldquest = true;
838 }
839
840 492 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(!oldquest)
864 {
865 492 delete_file(tmpfilename);
866 492 }
867
868 492 box_out("okay.");
869 492 box_eol();
870
871 492 return f;
872 824 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readmidis(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 824 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 210 times.
824 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 614 guys.setMax(255);
1132 614 items.setMax(255);
1133 614 Ewpns.setMax(255);
1134 614 Lwpns.setMax(255);
1135 614 chainlinks.setMax(255);
1136 614 decorations.setMax(255);
1137 614 particles.setMax(255);
1138 614 }
1139 else
1140 {
1141 210 guys.setMax(255);
1142 210 items.setMax(255);
1143 210 Ewpns.setMax(255);
1144 210 Lwpns.setMax(255);
1145 210 chainlinks.setMax(255);
1146 210 decorations.setMax(255);
1147 210 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 824 }
1150
1151 323 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 323 bool ret = true;
1154
1/2
✓ Branch 0 taken 323 times.
✗ Branch 1 not taken.
323 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 82688 times.
83011 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 323 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 1276322 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1199 {
1200 word v_weapon_data;
1201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1276322 times.
1276322 if(!p_igetw(&v_weapon_data,f))
1202 return qe_invalid;
1203
1204
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetw(&(data.flags), f))
1205 return qe_invalid;
1206
1207
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.moveflags), f))
1208 return qe_invalid;
1209
1210
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetw(&(data.wflags), f))
1211 return qe_invalid;
1212
1213
2/2
✓ Branch 0 taken 6381610 times.
✓ Branch 1 taken 1276322 times.
7657932 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1214 {
1215
1/2
✓ Branch 0 taken 6381610 times.
✗ Branch 1 not taken.
6381610 if (!p_getc(&(data.burnsprs[q]), f))
1216 return qe_invalid;
1217
1/2
✓ Branch 0 taken 6381610 times.
✗ Branch 1 not taken.
6381610 if (!p_getc(&(data.light_rads[q]), f))
1218 return qe_invalid;
1219 6381610 }
1220
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_getc(&(data.glow_shape), f))
1221 return qe_invalid;
1222
1223
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.override_flags), f))
1224 return qe_invalid;
1225
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.tilew), f))
1226 return qe_invalid;
1227
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.tileh), f))
1228 return qe_invalid;
1229
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.hxsz), f))
1230 return qe_invalid;
1231
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.hysz), f))
1232 return qe_invalid;
1233
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.hzsz), f))
1234 return qe_invalid;
1235
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.hxofs), f))
1236 return qe_invalid;
1237
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.hyofs), f))
1238 return qe_invalid;
1239
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.xofs), f))
1240 return qe_invalid;
1241
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.yofs), f))
1242 return qe_invalid;
1243
1244
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetzf(&(data.step), f))
1245 return qe_invalid;
1246
1247
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_getc(&(data.unblockable), f))
1248 return qe_invalid;
1249
1250
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetl(&(data.timeout), f))
1251 return qe_invalid;
1252
1253
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_getc(&(data.imitate_weapon), f))
1254 return qe_invalid;
1255
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_getc(&(data.default_defense), f))
1256 return qe_invalid;
1257
1258
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_getc(&(data.lift_level), f))
1259 return qe_invalid;
1260
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_getc(&(data.lift_time), f))
1261 return qe_invalid;
1262
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if (!p_igetzf(&(data.lift_height), f))
1263 return qe_invalid;
1264
1265
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if(!p_igetw(&(data.script), f))
1266 return qe_invalid;
1267
2/2
✓ Branch 0 taken 10210576 times.
✓ Branch 1 taken 1276322 times.
11486898 for(uint q = 0; q < 8; ++q)
1268
1/2
✓ Branch 0 taken 10210576 times.
✗ Branch 1 not taken.
10210576 if(!p_igetl(&(data.initd[q]), f))
1269 return qe_invalid;
1270
1/2
✓ Branch 0 taken 1276322 times.
✗ Branch 1 not taken.
1276322 if(!p_igetw(&(data.pierce_count), f))
1271 return qe_invalid;
1272 1276322 return 0;
1273 1276322 }
1274
1275 442 int32_t get_qst_buffers()
1276 {
1277 442 TheMaps.resize(MAPSCRS);
1278 442 old_combo_pages.resize(MAPSCRS);
1279 442 map_infos.resize(1);
1280
1281 442 Z_message("OK\n");
1282
1283 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1284 // (Shoelace's "Hero of Dreams" uses 1415.)
1285 // So let's be a bit generous and allow 4096 initially.
1286 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1287 // I tested it and it worked without flaw on 6/6/11. - L.
1288 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1289 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1290 // See https://discord.com/channels/876899628556091432/992984989073416242
1291 442 msg_strings_size = 8192;
1292
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442 times.
442 MsgStrings = new MsgStr[msg_strings_size];
1294
1295 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1296
2/2
✓ Branch 0 taken 3620864 times.
✓ Branch 1 taken 442 times.
3621306 for(auto q = 0; q < msg_strings_size; ++q)
1297 {
1298 3620864 MsgStrings[q].clear();
1299 3620864 }
1300
1301
4/6
✓ Branch 0 taken 226304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225862 times.
✓ Branch 3 taken 442 times.
✓ Branch 4 taken 442 times.
✗ Branch 5 not taken.
226304 if((DMaps=new dmap[MAXDMAPS])==NULL)
1302 return 0;
1303
1304
1305
1306 442 combobuf.clear();
1307 442 combobuf.resize(MAXCOMBOS);
1308
1309
1310
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1311 return 0;
1312
1313 442 free_newtilebuf();
1314
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1315 return 0;
1316
1317 442 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1318 //Z_message("Performed memset on tiles\n");
1319 442 clear_tiles(newtilebuf);
1320 //Z_message("Performed clear_tiles()\n");
1321
1322
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 15 times.
442 if (get_app_id() == App::zquest)
1323 {
1324
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1325 return 0;
1326
1327 15 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1328 15 clear_tiles(grabtilebuf);
1329 15 }
1330
1331
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((trashbuf=(byte*)malloc(100000))==NULL)
1332 return 0;
1333
1334 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1335 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1336 // fixed by ensuring there's actually itemdata there.
1337 // If you change this, be sure to update del_qst_buffers, too.
1338
1339
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1340 return 0;
1341
1342
2/2
✓ Branch 0 taken 113594 times.
✓ Branch 1 taken 442 times.
114036 for(size_t q = 0; q < MAXITEMS+1; ++q)
1343 113594 itemsbuf[q].clear();
1344 442 itemsbuf++;
1345
1346
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1347 return 0;
1348
1349 442 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1350
1351
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1352 return 0;
1353
1354
2/2
✓ Branch 0 taken 226304 times.
✓ Branch 1 taken 442 times.
226746 for(size_t q = 0; q < MAXGUYS; ++q)
1355 226304 guysbuf[q].clear();
1356
1357
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 442 return 1;
1361 442 }
1362
1363
1364 776 void free_newtilebuf()
1365 {
1366
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 439 times.
776 if(newtilebuf)
1367 {
1368
2/2
✓ Branch 0 taken 72286500 times.
✓ Branch 1 taken 337 times.
72286837 for(int32_t i=0; i<NEWMAXTILES; i++)
1369
2/2
✓ Branch 0 taken 643500 times.
✓ Branch 1 taken 71643000 times.
143929500 if(newtilebuf[i].data)
1370 71643000 free(newtilebuf[i].data);
1371
1372 337 free(newtilebuf);
1373 337 newtilebuf = 0;
1374 337 }
1375 776 }
1376
1377 334 void free_grabtilebuf()
1378 {
1379
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 11 times.
334 if (get_app_id() == App::zquest)
1380 {
1381
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1382 {
1383
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1385
1386 11 free(grabtilebuf);
1387 11 grabtilebuf = 0;
1388 11 }
1389 11 }
1390 334 }
1391
1392 334 void del_qst_buffers()
1393 {
1394
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
334 if(MsgStrings) delete[] MsgStrings;
1395
1396
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
334 if (DMaps) delete[] DMaps;
1397
1398 334 combobuf.clear();
1399
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(colordata) free(colordata);
1401
1402 334 free_newtilebuf();
1403 334 free_grabtilebuf();
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(trashbuf) free(trashbuf);
1406
1407 // See get_qst_buffers
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(itemsbuf)
1409 {
1410 334 itemsbuf--;
1411 334 free(itemsbuf);
1412 334 }
1413
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(wpnsbuf) free(wpnsbuf);
1415
1416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(guysbuf) free(guysbuf);
1417
1418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(combo_class_buf) free(combo_class_buf);
1419 334 }
1420
1421 18 bool init_palnames()
1422 {
1423 // if(palnames==NULL)
1424 // return false;
1425
1426
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1427 {
1428
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1429 {
1430 case 0:
1431 18 sprintf(palnames[x],"Overworld");
1432 18 break;
1433
1434 case 10:
1435 18 sprintf(palnames[x],"Caves");
1436 18 break;
1437
1438 case 11:
1439 18 sprintf(palnames[x],"Passageways");
1440 18 break;
1441
1442 default:
1443 9162 sprintf(palnames[x],"%c",0);
1444 9162 break;
1445 }
1446 9216 }
1447
1448 18 return true;
1449 }
1450
1451 100433 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1452 {
1453 void *p;
1454
1455
1/2
✓ Branch 0 taken 100433 times.
✗ Branch 1 not taken.
100433 p = _AL_MALLOC(MAX(size, alloc_size));
1456
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100433 times.
100433 if(!p)
1458 {
1459 return NULL;
1460 }
1461
1462
1/2
✓ Branch 0 taken 100433 times.
✗ Branch 1 not taken.
100433 if(!pfread(p,size,f))
1463 {
1464 _AL_FREE(p);
1465 return NULL;
1466 }
1467
1468
1/2
✓ Branch 0 taken 100433 times.
✗ Branch 1 not taken.
100433 if(pack_ferror(f))
1469 {
1470 _AL_FREE(p);
1471 return NULL;
1472 }
1473
1474 100433 return p;
1475 100433 }
1476
1477 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1478 static const byte* legacy_skip_flags;
1479
1480 /* read_midi:
1481 * Reads MIDI data from a datafile (this is not the same thing as the
1482 * standard midi file format).
1483 */
1484
1485 10302 static MIDI *read_midi(PACKFILE *f)
1486 {
1487 MIDI *m;
1488 int32_t c;
1489 10302 int16_t divisions=0;
1490 10302 int32_t len=0;
1491
1492 10302 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1493
1494
1/2
✓ Branch 0 taken 10302 times.
✗ Branch 1 not taken.
10302 if(!m)
1495 {
1496 return NULL;
1497 }
1498
1499
2/2
✓ Branch 0 taken 329664 times.
✓ Branch 1 taken 10302 times.
339966 for(c=0; c<MIDI_TRACKS; c++)
1500 {
1501 329664 m->track[c].len = 0;
1502 329664 m->track[c].data = NULL;
1503 329664 }
1504
1505 10302 p_mgetw(&divisions,f);
1506 10302 m->divisions=divisions;
1507
1508
2/2
✓ Branch 0 taken 329664 times.
✓ Branch 1 taken 10302 times.
339966 for(c=0; c<MIDI_TRACKS; c++)
1509 {
1510 329664 p_mgetl(&len,f);
1511 329664 m->track[c].len=len;
1512
1513
2/2
✓ Branch 0 taken 229231 times.
✓ Branch 1 taken 100433 times.
329664 if(m->track[c].len > 0)
1514 {
1515 100433 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1516
1517
1/2
✓ Branch 0 taken 100433 times.
✗ Branch 1 not taken.
100433 if(!m->track[c].data)
1518 {
1519 destroy_midi(m);
1520 return NULL;
1521 }
1522 100433 }
1523 329664 }
1524
1525 LOCK_DATA(m, sizeof(MIDI));
1526
1527
2/2
✓ Branch 0 taken 329664 times.
✓ Branch 1 taken 10302 times.
339966 for(c=0; c<MIDI_TRACKS; c++)
1528 {
1529
2/2
✓ Branch 0 taken 100433 times.
✓ Branch 1 taken 229231 times.
329664 if(m->track[c].data)
1530 {
1531 LOCK_DATA(m->track[c].data, m->track[c].len);
1532 100433 }
1533 329664 }
1534
1535 10302 return m;
1536 10302 }
1537
1538 void clear_combo(int32_t i)
1539 {
1540 combobuf[i].clear();
1541 }
1542
1543 void clear_combos()
1544 {
1545 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1546 clear_combo(tmpcounter);
1547 }
1548
1549 void pack_combos()
1550 {
1551 int32_t di = 0;
1552
1553 for(int32_t si=0; si<1024; si+=2)
1554 combobuf[di++] = combobuf[si];
1555
1556 for(; di<1024; di++)
1557 clear_combo(di);
1558 }
1559
1560 492 void reset_tunes(zctune *tune)
1561 {
1562
2/2
✓ Branch 0 taken 123984 times.
✓ Branch 1 taken 492 times.
124476 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1563 {
1564 123984 tune[i].reset();
1565 123984 }
1566 492 }
1567
1568 int32_t doortranslations_u[9][4]=
1569 {
1570 {37,38,53,54},
1571 {37,38,39,40},
1572 {37,38,55,56},
1573 {37,38,39,40},
1574 {37,38,53,54},
1575 {37,38,53,54},
1576 {37,38,53,54},
1577 {7,8,23,24},
1578 {7,8,41,42}
1579 };
1580
1581 int32_t doortranslations_d[9][4]=
1582 {
1583 {117,118,133,134},
1584 {135,136,133,134},
1585 {119,120,133,134},
1586 {135,136,133,134},
1587 {117,118,133,134},
1588 {117,118,133,134},
1589 {117,118,133,134},
1590 {151,152,167,168},
1591 {137,138,167,168},
1592 };
1593
1594 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1595 int32_t doortranslations_l[9][6]=
1596 {
1597 {66,67,82,83,98,99},
1598 {66,68,82,84,98,100},
1599 {66,69,82,85,98,101},
1600 {66,68,82,84,98,100},
1601 {66,67,82,83,98,99},
1602 {66,67,82,83,98,99},
1603 {66,67,82,83,98,99},
1604 {64,65,80,81,96,97},
1605 {64,65,80,114,96,97},
1606 };
1607
1608 int32_t doortranslations_r[9][6]=
1609 {
1610
1611 {76,77,92,93,108,109},
1612 {75,77,91,93,107,109},
1613 {74,77,90,93,106,109},
1614 {75,77,91,93,107,109},
1615 {76,77,92,93,108,109},
1616 {76,77,92,93,108,109},
1617 {76,77,92,93,108,109},
1618 {78,79,94,95,110,111},
1619 {78,79,125,95,110,111},
1620 };
1621
1622 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1623 {
1624 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1625 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1626 }
1627
1628 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1629 {
1630 //these are here to bypass compiler warnings about unused arguments
1631 840750 map=map;
1632 840750 scr=scr;
1633 840750 pos=pos;
1634
1635 //what does this function do?
1636 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1637 840750 return 2;
1638 }
1639
1640 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1641 {
1642
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1643 {
1644 18423 return 0;
1645 }
1646
1647 4425 DoorComboSet tempdcs{};
1648
1649 //up
1650
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1651 {
1652
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1653 {
1654 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1655 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1656 159300 }
1657 39825 }
1658
1659 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1660 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1661 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1662 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1663 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1664 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1665
1666 //down
1667
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1668 {
1669
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1670 {
1671 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1672 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1673 159300 }
1674 39825 }
1675
1676 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1677
1678 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1679 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1680 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1681 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1683
1684 //left
1685 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1686
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1687 {
1688
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1689 {
1690 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1691 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1692 238950 }
1693 39825 }
1694
1695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1696 {
1697 if((j!=2)&&(j!=3))
1698 {
1699 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1700 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1701 }
1702 }
1703
1704 4425 tempdcs.bombdoorcombo_l[0]=0;
1705 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1706 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1707 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1708 4425 tempdcs.bombdoorcombo_l[2]=0;
1709 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1710 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1711 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1712
1713 //right
1714
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1715 {
1716
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1717 {
1718 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1719 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1720 238950 }
1721 39825 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1724 {
1725 if((j!=2)&&(j!=3))
1726 {
1727 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1728 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1729 }
1730 }
1731
1732 4425 tempdcs.bombdoorcombo_r[0]=0;
1733 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1734 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1735 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1736 4425 tempdcs.bombdoorcombo_r[2]=0;
1737 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1738 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1739 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1740
1741 int32_t k;
1742
1743
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1744 {
1745
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1746 {
1747 4365 break;
1748 }
1749 5941 }
1750
1751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1752 {
1753 return 0;
1754 }
1755
1756
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1757 {
1758 60 DoorComboSets[k]=tempdcs;
1759 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1760 60 ++door_combo_set_count;
1761 60 }
1762
1763 4425 return k;
1764 /*
1765 doorcombo_u[9][4];
1766 doorcset_u[9][4];
1767 doorcombo_d[9][4];
1768 doorcset_d[9][4];
1769 doorcombo_l[9][6];
1770 doorcset_l[9][6];
1771 doorcombo_r[9][6];
1772 doorcset_r[9][6];
1773 bombdoorcombo_u[2];
1774 bombdoorcset_u[2];
1775 bombdoorcombo_d[2];
1776 bombdoorcset_d[2];
1777 bombdoorcombo_l[3];
1778 bombdoorcset_l[3];
1779 bombdoorcombo_r[3];
1780 bombdoorcset_r[3];
1781 walkthroughcombo[4];
1782 walkthroughcset[4];
1783 */
1784 22848 }
1785
1786 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1787 {
1788 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1789 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1790 }
1791
1792 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1793 {
1794
1795 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1796 }
1797
1798 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1799 {
1800 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1801 }
1802
1803
1804 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1805 {
1806 char temp_pwd[30];
1807 83 memset(temp_pwd,0,30);
1808
1809
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1810 {
1811 75 memcpy(temp_pwd,encrypted_pwd,30);
1812 75 temp_pwd[29]=0;
1813
1814
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1815 {
1816 2250 temp_pwd[i] -= pwdkey;
1817 2250 int32_t t=pwdkey>>15;
1818 2250 pwdkey = (pwdkey<<1)+t;
1819 2250 }
1820 75 }
1821
1822 83 memcpy(pwd,temp_pwd,30);
1823 83 }
1824
1825
1826 262 bool devpwd()
1827 {
1828 #ifdef _DEBUG
1829 return true;
1830 #endif
1831 #if DEVLEVEL > 3
1832 return true;
1833 #endif
1834
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1835 }
1836 bool check_questpwd(zquestheader *Header, char *pwd)
1837 {
1838 if(devpwd())
1839 return true;
1840 if((!strcmp(pwd, (char*)clavio)))
1841 return true;
1842 cvs_MD5Context ctx;
1843 uint8_t md5sum[16];
1844
1845 cvs_MD5Init(&ctx);
1846 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1847 cvs_MD5Final(md5sum, &ctx);
1848
1849 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1850 }
1851
1852 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1853 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1854 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1855
1856 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1857 {
1858 char keyfilename[2048];
1859 replace_extension(keyfilename, path, ext, 2047);
1860 if(!exists(keyfilename))
1861 return false;
1862 bool ret = false;
1863
1864 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1865 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1866 char msg[80] = {0};
1867 pfread(msg, 80, fp);
1868 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1869 {
1870 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1871 pack_fclose(fp);
1872 return false;
1873 }
1874 int16_t ver;
1875 byte bld;
1876 p_igetw(&ver, fp);
1877 p_getc(&bld, fp);
1878 pfread(password, QSTPWD_LEN, fp, true);
1879 if(hashed)
1880 {
1881 char unhashed_pw[QSTPWD_LEN] = {0};
1882
1883 char hashmap = 'Z';
1884 hashmap += 'Q';
1885 hashmap += 'U';
1886 hashmap += 'E';
1887 hashmap += 'S';
1888 hashmap += 'T';
1889
1890 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1891 unhashed_pw[q] = password[q] - hashmap;
1892
1893 ret = check_questpwd(Header, unhashed_pw);
1894 }
1895 else ret = check_questpwd(Header, password);
1896 pack_fclose(fp);
1897 zprint2("Found %s Key File '%s' (%s access)\n",
1898 typestr, keyfilename, ret ? "valid" : "invalid");
1899 return ret;
1900 }
1901
1902 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1903 {
1904 char exedir[PATH_MAX] = {0};
1905 extract_name(path, exedir, FILENAMEALL);
1906 char const* paths[] = {path, exedir};
1907 for(uint keyty : types)
1908 {
1909 if(keyty >= KEYFILE_NUMTY)
1910 continue;
1911 for(char const* p : paths)
1912 {
1913 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1914 return true;
1915 }
1916 }
1917 return false;
1918 }
1919
1920 493 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1921 {
1922 493 zprint2("\n");
1923 493 zprint2("[QUEST METADATA]\n");
1924
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 if(path)
1925 493 zprint2("Path: %s\n", path);
1926
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 124 times.
493 if(tempheader.title[0])
1927 369 zprint2("Title: %s\n", tempheader.title);
1928 493 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1929
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 283 times.
493 if(tempheader.new_version_id_date_day)
1930 210 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1931
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 216 times.
493 if(tempheader.version[0])
1932 277 zprint2("Qst Version: %s\n", tempheader.version);
1933
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 124 times.
493 if(tempheader.author[0])
1934 369 zprint2("Author: %s\n", tempheader.author);
1935 493 zprint2("\n");
1936 493 }
1937
1938 836 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1939 {
1940 int32_t dummy;
1941 836 zquestheader tempheader{};
1942
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 12 times.
836 tempheader.filename = Header->filename;
1943 char dummybuf[80];
1944 byte temp_map_count;
1945 byte temp_midi_flags[MIDIFLAGS_SIZE];
1946 word version;
1947 char temp_pwd[30], temp_pwd2[30];
1948 int16_t temp_pwdkey;
1949 cvs_MD5Context ctx;
1950 824 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1951 824 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1952
1953
1954
1955
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1956 {
1957 Z_message("Unable to read header string\n");
1958 return qe_invalid;
1959 }
1960
1961 // check header
1962
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 24 times.
824 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1963 {
1964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1965 {
1966 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1967 return qe_invalid;
1968 }
1969 24 }
1970
1971 824 int32_t templatepath_len=0;
1972
1973 824 tempheader.external_zinfo = false;
1974 824 read_zinfo = false;
1975
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1976 {
1977 byte padding;
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1990
1991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1992 {
1993 return qe_version;
1994 }
1995
1996 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1997
1998
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1999 {
2000 return qe_invalid;
2001 }
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
2004 {
2005 return qe_obsolete;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2019
2020
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2021 {
2022 return qe_invalid;
2023 }
2024
2025
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2026 {
2027 return qe_invalid;
2028 }
2029
2030 24 FFCore.quest_format[qMapCount] = temp_map_count;
2031
2032
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2033 {
2034 return qe_invalid;
2035 }
2036
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2048 {
2049 return qe_invalid;
2050 }
2051
2052
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2053 {
2054 return qe_invalid;
2055 }
2056
2057
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2058 {
2059 return qe_invalid;
2060 }
2061
2062
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2063 {
2064 return qe_invalid;
2065 }
2066
2067
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2068 {
2069 return qe_invalid;
2070 }
2071
2072
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2073 {
2074 return qe_invalid;
2075 }
2076 // These fields are expected to end in null bytes!
2077 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2078
2079
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2080 {
2081 return qe_invalid;
2082 }
2083 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2084
2085
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2086 {
2087 return qe_invalid;
2088 }
2089
2090
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2091 {
2092 return qe_invalid;
2093 }
2094
2095
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2096 {
2097 return qe_invalid;
2098 }
2099
2100 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2102
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2103
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2104
2105
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2106 {
2107 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2108 // Not anymore...
2109 memset(tempheader.minver,0,17);
2110 tempheader.build=0;
2111 tempheader.use_keyfile=0;
2112 memset(tempheader.old_foo, 0, 9);
2113 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2117 {
2118 return qe_invalid;
2119 }
2120
2121
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2122 {
2123 return qe_invalid;
2124 }
2125
2126 24 FFCore.quest_format[vBuild] = tempheader.build;
2127
2128
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2134 {
2135 return qe_invalid;
2136 }
2137 } // starting at minver
2138
2139
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2140 {
2141 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2142 6 }
2143 else
2144 {
2145
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at rules3
2148 }
2149
2150
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2151 {
2152
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2153 12 }
2154 }
2155
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2156
2157
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2158
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2159 {
2160
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2161
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2162
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2163 18 }
2164
2165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2166 {
2167 6 byte *mf=temp_midi_flags;
2168
2169
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2170 {
2171 4 mf=(byte*)dummybuf;
2172 4 }
2173
2174
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2175 {
2176 return qe_invalid; // starting at foo2
2177 }
2178
2179
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2180 {
2181 return qe_invalid; // starting at foo2
2182 }
2183 6 }
2184
2185
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2186
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2187 {
2188 18 memset(tempheader.templatepath,0,2048);
2189 18 }
2190 else
2191 {
2192 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2193 {
2194 return qe_invalid;
2195 }
2196 }
2197
2198
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2199
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2200 {
2201 24 tempheader.use_keyfile=0;
2202 24 }
2203 24 }
2204 else
2205 {
2206 //section id
2207
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_mgetl(&dummy,f))
2208 {
2209 return qe_invalid;
2210 }
2211
2212 //section version info
2213
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetw(&version,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (version > V_HEADER)
2219 return qe_version;
2220
2221 800 FFCore.quest_format[vHeader] = version;
2222
2223
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetw(&dummy,f))
2224 {
2225 return qe_invalid;
2226 }
2227
2228 //section size
2229
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetl(&dummy,f))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 //finally... section data
2235
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetw(&tempheader.zelda_version,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 800 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2241
2242 //do some quick checking...
2243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(tempheader.zelda_version > ZELDA_VERSION)
2244 {
2245 return qe_version;
2246 }
2247
2248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2249 {
2250 return qe_invalid;
2251 }
2252
2253
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(bad_version(tempheader.zelda_version))
2254 {
2255 return qe_obsolete;
2256 }
2257
2258
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_getc(&tempheader.build,f))
2259 {
2260 return qe_invalid;
2261 }
2262
2263 800 FFCore.quest_format[vBuild] = tempheader.build;
2264
2265
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 741 times.
800 if(version<3)
2266 {
2267
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2268 {
2269 return qe_invalid;
2270 }
2271
2272
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2273 {
2274 return qe_invalid;
2275 }
2276
2277 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2278
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2279
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2280
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2281 59 }
2282 else
2283 {
2284
2/4
✓ Branch 0 taken 741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
741 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2285 {
2286 return qe_invalid;
2287 }
2288 }
2289
2290
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetw(&tempheader.internal,f))
2291 {
2292 return qe_invalid;
2293 }
2294
2295
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_getc(&tempheader.quest_number,f))
2296 {
2297 return qe_invalid;
2298 }
2299
2300 800 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2301
2302 800 size_t versz = version < 8 ? 9 : 16;
2303
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(tempheader.version,versz,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2309 //needs to be copied as char[9] or stored as a s.str
2310
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(tempheader.minver,versz,f))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2316
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2317 {
2318 return qe_invalid;
2319 }
2320 800 tempheader.title[sizeof(tempheader.title)-1] = 0;
2321
2322
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2323 {
2324 return qe_invalid;
2325 }
2326 800 tempheader.author[sizeof(tempheader.author)-1] = 0;
2327
2328
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_getc(&tempheader.use_keyfile,f))
2329 {
2330 return qe_invalid;
2331 }
2332
2333 /*
2334 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2335 {
2336 return qe_invalid;
2337 }
2338 */
2339
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2340 {
2341 return qe_invalid;
2342 }
2343
2344
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(&dummybuf,4,f))
2345 {
2346 return qe_invalid;
2347 }
2348
2349
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(dummybuf,14,f))
2355 {
2356 return qe_invalid;
2357 }
2358
2359 800 templatepath_len=sizeof(tempheader.templatepath);
2360
2361
2/2
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 59 times.
800 if(version==1)
2362 {
2363 59 templatepath_len=280;
2364 59 }
2365
2366
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!pfread(tempheader.templatepath,templatepath_len,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2371
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_getc(&temp_map_count,f))
2372 {
2373 return qe_invalid;
2374 }
2375
2376
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 590 times.
800 if(version>=4)
2377 {
2378
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.version_major,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.version_minor,f))
2383 {
2384 return qe_invalid;
2385 }
2386
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.version_patch,f))
2387 {
2388 return qe_invalid;
2389 }
2390
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2391 {
2392 return qe_invalid;
2393 }
2394
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2395 {
2396 return qe_invalid;
2397 }
2398
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.new_version_id_beta,f))
2399 {
2400 return qe_invalid;
2401 }
2402
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2403 {
2404 return qe_invalid;
2405 }
2406
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.new_version_id_release,f))
2407 {
2408 return qe_invalid;
2409 }
2410
2411 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2412
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
210 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2413 tempheader.version_minor = 55;
2414
2415
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2416 {
2417 return qe_invalid;
2418 }
2419
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&tempheader.new_version_id_date_month,f))
2420 {
2421 return qe_invalid;
2422 }
2423
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&tempheader.new_version_id_date_day,f))
2424 {
2425 return qe_invalid;
2426 }
2427
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2436
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.new_version_devsig,256,f))
2437 {
2438 return qe_invalid;
2439 }
2440
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2441 strcpy(tempheader.new_version_devsig, "EmilyV99");
2442
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.new_version_compilername,256,f))
2443 {
2444 return qe_invalid;
2445 }
2446
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.new_version_compilerversion,256,f))
2447 {
2448 return qe_invalid;
2449 }
2450
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.product_name,1024,f))
2451 {
2452 return qe_invalid;
2453 }
2454
2455
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&tempheader.compilerid,f))
2456 {
2457 return qe_invalid;
2458 }
2459
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2460 {
2461 return qe_invalid;
2462 }
2463
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2468 {
2469 return qe_invalid;
2470 }
2471
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2472 {
2473 return qe_invalid;
2474 }
2475
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetw(&tempheader.developerid,f))
2476 {
2477 return qe_invalid;
2478 }
2479
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.made_in_module_name,1024,f))
2480 {
2481 return qe_invalid;
2482 }
2483
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.build_datestamp,256,f))
2484 {
2485 return qe_invalid;
2486 }
2487
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.build_timestamp,256,f))
2488 {
2489 return qe_invalid;
2490 }
2491 210 }
2492 else // <4
2493 {
2494 590 tempheader.version_major = 0;
2495 590 tempheader.version_minor = 0;
2496 590 tempheader.version_patch = 0;
2497 590 tempheader.new_version_id_fourth = 0;
2498 590 tempheader.new_version_id_alpha = 0;
2499 590 tempheader.new_version_id_beta = 0;
2500 590 tempheader.new_version_id_gamma = 0;
2501 590 tempheader.new_version_id_release = 0;
2502 590 tempheader.new_version_id_date_year = 0;
2503 590 tempheader.new_version_id_date_month = 0;
2504 590 tempheader.new_version_id_date_day = 0;
2505 590 tempheader.new_version_id_date_hour = 0;
2506 590 tempheader.new_version_id_date_minute = 0;
2507
2508 590 memset(tempheader.new_version_devsig, 0, 256);
2509 590 memset(tempheader.new_version_compilername, 0, 256);
2510 590 memset(tempheader.new_version_compilerversion, 0, 256);
2511 590 memset(tempheader.product_name, 0, 1024);
2512 590 strcpy(tempheader.product_name, "ZQuest Classic");
2513
2514 590 tempheader.compilerid = 0;
2515 590 tempheader.compilerversionnumber_first = 0;
2516 590 tempheader.compilerversionnumber_second = 0;
2517 590 tempheader.compilerversionnumber_third = 0;
2518 590 tempheader.compilerversionnumber_fourth = 0;
2519 590 tempheader.developerid = 0;
2520
2521 590 memset(tempheader.made_in_module_name, 0, 1024);
2522 590 memset(tempheader.build_datestamp, 0, 256);
2523 590 memset(tempheader.build_timestamp, 0, 256);
2524 }
2525
2526
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 590 times.
800 if ( version >= 5 )
2527 {
2528
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(tempheader.build_timezone,6,f))
2529 {
2530 return qe_invalid;
2531 }
2532 210 }
2533 else // < 5
2534 {
2535 590 memset(tempheader.build_timezone, 0, 6);
2536 }
2537
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 590 times.
800 if ( version >= 6 )
2538 {
2539 byte b;
2540
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&b,f))
2541 {
2542 return qe_invalid;
2543 }
2544 210 tempheader.external_zinfo = b?true:false;
2545 210 read_zinfo = true;
2546 210 }
2547
2548
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 590 times.
800 if(version >= 7)
2549 {
2550
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2551 {
2552 return qe_invalid;
2553 }
2554 210 }
2555 else
2556 {
2557 590 tempheader.new_version_is_nightly = false;
2558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590 times.
590 if(tempheader.zelda_version < 0x255)
2559 {
2560
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
590 switch(tempheader.zelda_version)
2561 {
2562 case 0x254:
2563 tempheader.version_major = 2;
2564 tempheader.version_minor = 54;
2565 break;
2566 case 0x250:
2567
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 412 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 13 times.
531 switch(tempheader.build)
2568 {
2569 case 19:
2570 tempheader.version_major = 2;
2571 tempheader.version_minor = 50;
2572 tempheader.new_version_id_gamma = 1;
2573 break;
2574 case 20:
2575 tempheader.version_major = 2;
2576 tempheader.version_minor = 50;
2577 tempheader.new_version_id_gamma = 2;
2578 break;
2579 case 21:
2580 tempheader.version_major = 2;
2581 tempheader.version_minor = 50;
2582 tempheader.new_version_id_gamma = 3;
2583 break;
2584 case 22:
2585 tempheader.version_major = 2;
2586 tempheader.version_minor = 50;
2587 tempheader.new_version_id_gamma = 4;
2588 break;
2589 case 23:
2590 tempheader.version_major = 2;
2591 tempheader.version_minor = 50;
2592 tempheader.new_version_id_gamma = 5;
2593 break;
2594 case 24:
2595 31 tempheader.version_major = 2;
2596 31 tempheader.version_minor = 50;
2597 31 tempheader.new_version_id_release = -1;
2598 31 break;
2599 case 25:
2600 tempheader.version_major = 2;
2601 tempheader.version_minor = 50;
2602 tempheader.version_patch = 1;
2603 tempheader.new_version_id_gamma = 1;
2604 break;
2605 case 26:
2606 24 tempheader.version_major = 2;
2607 24 tempheader.version_minor = 50;
2608 24 tempheader.version_patch = 1;
2609 24 tempheader.new_version_id_gamma = 2;
2610 24 break;
2611 case 27:
2612 tempheader.version_major = 2;
2613 tempheader.version_minor = 50;
2614 tempheader.version_patch = 1;
2615 tempheader.new_version_id_gamma = 3;
2616 break;
2617 case 28:
2618 6 tempheader.version_major = 2;
2619 6 tempheader.version_minor = 50;
2620 6 tempheader.version_patch = 1;
2621 6 tempheader.new_version_id_release = -1;
2622 6 break;
2623 case 29:
2624 412 tempheader.version_major = 2;
2625 412 tempheader.version_minor = 50;
2626 412 tempheader.version_patch = 2;
2627 412 tempheader.new_version_id_release = -1;
2628 412 break;
2629 case 30:
2630 tempheader.version_major = 2;
2631 tempheader.version_minor = 50;
2632 tempheader.version_patch = 3;
2633 tempheader.new_version_id_gamma = 1;
2634 break;
2635 case 31:
2636 16 tempheader.version_major = 2;
2637 16 tempheader.version_minor = 53;
2638 16 tempheader.new_version_id_gamma = -1;
2639 16 break;
2640 case 32:
2641 29 tempheader.version_major = 2;
2642 29 tempheader.version_minor = 53;
2643 29 tempheader.new_version_id_release = -1;
2644 29 break;
2645 case 33:
2646 13 tempheader.version_major = 2;
2647 13 tempheader.version_minor = 53;
2648 13 tempheader.version_patch = 1;
2649 13 break;
2650 }
2651 531 break;
2652
2653 case 0x211:
2654 tempheader.version_major = 2;
2655 tempheader.version_minor = 11;
2656 tempheader.new_version_id_beta = tempheader.build;
2657 break;
2658 case 0x210:
2659 59 tempheader.version_major = 2;
2660 59 tempheader.version_minor = 10;
2661 59 tempheader.new_version_id_beta = tempheader.build;
2662 59 break;
2663 }
2664 590 }
2665 }
2666
2667
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 634 times.
800 if (version>=9)
2668 {
2669 166 std::string version_string;
2670
2/4
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 if(!p_getcstr(&version_string, f))
2671 {
2672 return qe_invalid;
2673 }
2674
2675 166 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2676 166 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 }
2678 else
2679 {
2680 634 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2681 }
2682 }
2683
2684
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 766 times.
824 if(printmetadata)
2685 {
2686
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2687 58 }
2688
2689 //{ Version Warning
2690
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 int32_t vercmp = tempheader.compareVer();
2691
3/6
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 824 times.
✗ Branch 5 not taken.
824 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2692
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2693
4/6
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 658 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 166 times.
990 if(vercmp > 0 || (!vercmp &&
2694
2/4
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 (astatecmp > 0 || (!astatecmp &&
2695 166 avercmp > 0))))
2696 {
2697 bool r = true;
2698 if(loadquest_report)
2699 {
2700 enter_sys_pal();
2701 AlertDialog("Quest saved in newer version",
2702 "This quest was last saved in a newer version of ZQuest."
2703 " Attempting to load this quest may not work correctly; to"
2704 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2705 "\n\nWould you like to continue loading anyway? (Not recommended)",
2706 [&](bool ret,bool)
2707 {
2708 r = ret;
2709 }).show();
2710 exit_sys_pal();
2711 }
2712 if(!r)
2713 return qe_silenterr;
2714 }
2715 //}
2716
2717 824 read_ext_zinfo = tempheader.external_zinfo;
2718
2719
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 *Header = tempheader;
2720 824 map_count=temp_map_count;
2721 824 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2722
2723
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 unpack_qrs();
2724
2725 824 return 0;
2726 848 }
2727
2728 11402 int32_t readrules(PACKFILE *f, zquestheader *Header)
2729 {
2730
2/2
✓ Branch 0 taken 11379 times.
✓ Branch 1 taken 23 times.
11402 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11402 times.
11402 if (should_skip)
2732 return 0;
2733
2734 int32_t dummy;
2735 11402 zquestheader tempheader = *Header;
2736 11402 word s_version=0;
2737 11402 dword compatrule_version=0;
2738
2739
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 10933 times.
11402 if(tempheader.zelda_version >= 0x193)
2740 {
2741 //section version info
2742
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&s_version,f))
2743 {
2744 return qe_invalid;
2745 }
2746
2747
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (s_version > V_RULES)
2748 return qe_version;
2749
2750 469 FFCore.quest_format[vRules] = s_version;
2751
2752
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&dummy,f))
2753 {
2754 return qe_invalid;
2755 }
2756
2757
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 259 times.
469 if(s_version > 16)
2758 {
2759
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetl(&compatrule_version,f))
2760 {
2761 return qe_invalid;
2762 }
2763 210 }
2764 469 FFCore.quest_format[vCompatRule] = compatrule_version;
2765
2766 //section size
2767
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetl(&dummy,f))
2768 {
2769 return qe_invalid;
2770 }
2771
2772
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 210 times.
469 if ( s_version < 15 )
2773 {
2774 //finally... section data
2775
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2776 {
2777 return qe_invalid;
2778 }
2779 259 }
2780 else
2781 {
2782
2783
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2784 {
2785 return qe_invalid;
2786 }
2787
2788 }
2789 469 }
2790
2791 //{ bunch of compat stuff
2792 11402 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2793
2794
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 10910 times.
11402 unpack_qrs();
2795
2796
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<2)
2797 {
2798
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2799
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2800
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2801
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2802
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2803
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2804
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2805
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2806
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2807
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2809
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2810
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2811
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2812
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2813
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2814
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2815
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2816
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2817 82 }
2818
2819 //Now, do any updates...
2820
3/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
492 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2821 {
2822
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2823
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2824
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2825
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2826
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2827 82 }
2828
2829
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
492 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2830 {
2831
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2832 23 }
2833
2834
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
492 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2835 {
2836
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2837 23 }
2838
2839
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
492 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2840 {
2841
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2842 23 }
2843
2844
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(tempheader.zelda_version <= 0x210)
2845 {
2846
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2847 82 }
2848
2849
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 433 times.
492 if(tempheader.zelda_version == 0x210)
2850 {
2851
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2852
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2853
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2854 59 }
2855
2856
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(tempheader.zelda_version <= 0x210)
2857 {
2858
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2859
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2860 82 }
2861
2862 //might not be correct
2863
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 469 times.
492 if(tempheader.zelda_version < 0x210)
2864 {
2865
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2866
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2867
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2868 23 }
2869
2870
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(tempheader.zelda_version < 0x211)
2871 {
2872
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2873 82 }
2874
2875
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 487 times.
492 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2876 {
2877
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 470 times.
492 set_qr(qr_192b163_WARP,1);
2878 22 }
2879
2880
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 37 times.
22 if(tempheader.zelda_version == 0x210)
2881 {
2882
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2883
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2884
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2885 59 }
2886
2887
3/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
96 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2888 {
2889
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 232 times.
314 set_qr(qr_OLDPICKUP,1);
2890 82 }
2891
2892
3/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
492 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2893 {
2894
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2895
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2896 82 }
2897
2898
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2899 {
2900
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2901 82 }
2902
2903
4/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 169 times.
492 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2904 {
2905
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_PEAHATCLOCKVULN, 1);
2906 31 }
2907
2908
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
492 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2909 {
2910
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 set_qr(qr_OLD_DOORREPAIR, 1);
2911 82 }
2912
2913
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
292 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2914 {
2915
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 236 times.
318 set_qr(qr_OLD_SECRETMONEY, 1);
2916 82 }
2917
2918
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
292 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2919 {
2920
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 181 times.
318 set_qr(qr_OLD_POTION_OR_HC, 1);
2921 137 }
2922
2923
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
347 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2924 {
2925
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 126 times.
263 set_qr(qr_OFFSCREENWEAPONS, 1);
2926 137 }
2927
2928 //Bombchu fix.
2929
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 200 times.
347 if(tempheader.zelda_version == 0x250)
2930 {
2931
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 169 times.
200 if ( tempheader.build == 24 ) //2.50.0
2932 {
2933
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2934 31 }
2935
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 194 times.
200 if ( tempheader.build == 28 ) //2.50.1
2936 {
2937
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2938 6 }
2939
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 119 times.
200 if ( tempheader.build == 29 ) //2.50.2
2940 {
2941
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2942 81 }
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if ( tempheader.build == 30 ) //2.50.3RC1
2944 {
2945 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2946 }
2947 200 }
2948
2949
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
361 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2950 {
2951 // qr_OFFSETEWPNCOLLISIONFIX
2952 // All 'official' quests need this disabled.
2953 // All 2.10 and lower quests need this enabled to preseve compatability.
2954 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2955
2956 //~Gleeok
2957
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 106 times.
249 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2958
2959 // Broke in build 695
2960
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
143 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2961
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 set_qr(qr_BROKENSTATUES, 1);
2962 143 }
2963
11/14
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 590 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 590 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 573 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
353 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2964 {
2965
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2966 22 }
2967
8/8
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 395 times.
✓ Branch 2 taken 305 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 223 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 210 times.
✓ Branch 7 taken 13 times.
595 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2968 {
2969
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 313 times.
582 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2970 269 }
2971
2972
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2973 {
2974
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2975 82 }
2976
2977
4/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 210 times.
282 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2978 {
2979
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 166 times.
116 set_qr(qr_STEP_IS_FLOAT,0);
2980 282 }
2981
2982
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if ( tempheader.zelda_version < 0x250 )
2983 {
2984
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2985 82 }
2986
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version < 3)
2988 {
2989
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2990
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2991 82 }
2992
2993
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<4)
2994 {
2995
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2996 82 }
2997
2998
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<5)
2999 {
3000
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
3001 82 }
3002
3003
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<6)
3004 {
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
3006 82 }
3007
3008
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<7) // January 2008
3009 {
3010
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
3011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3012 82 }
3013
3014
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<8)
3015 {
3016
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3017 82 }
3018 else
3019 {
3020
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 set_bit(deprecated_rules, 12, 0);
3021 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<9) // October 2008
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3026
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3027
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3028
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3029 82 }
3030
3031
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<10) // December 2008
3032 {
3033
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3034
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3035 82 }
3036
3037
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version<11) // April 2009
3038 {
3039
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3040 82 }
3041
3042 // This served no purpose.
3043 // if(s_version<12) // December 2009
3044 // {
3045 // set_qr(qr_BRKBLSHLDS_DEP,0);
3046 // set_qr(qr_OLDTRIBBLES_DEP,0);
3047 // }
3048
3049 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3050
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(s_version < 13)
3051 {
3052
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3053 82 }
3054
3055 // Not entirely sure this is the best place for this...
3056 //2.50.2 bitmap offset fix
3057 492 memset(extra_rules, 0, EXTRARULES_SIZE);
3058
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
492 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3059 {
3060
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 139 times.
282 set_er(er_BITMAPOFFSET, 1);
3061
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 set_qr(qr_BITMAPOFFSETFIX, 1);
3062 143 }
3063 //required because quest templates also used this bit, although
3064 //it never did anything, before. -Z
3065
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 165 times.
353 if ( tempheader.zelda_version == 0x250 )
3066 {
3067
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 103 times.
200 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3068 {
3069
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_er(er_BITMAPOFFSET, 0);
3070
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_qr(qr_BITMAPOFFSETFIX, 0);
3071 97 }
3072 200 }
3073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
365 if ( tempheader.zelda_version == 0x254 )
3074 {
3075 set_er(er_BITMAPOFFSET, 0);
3076 set_qr(qr_BITMAPOFFSETFIX, 0);
3077 }
3078
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 210 times.
365 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3079 {
3080 set_er(er_BITMAPOFFSET, 0);
3081 set_qr(qr_BITMAPOFFSETFIX, 0);
3082 }
3083 //optimise fast drawing for older versions.
3084
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
365 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3085 {
3086
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 113 times.
365 set_qr(qr_OLDSPRITEDRAWS, 1);
3087 282 }
3088 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3089 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3090 //older quests can set the rule by hand. We need a new qst.dat again.
3091
4/4
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420 times.
420 set_qr(qr_OLDEWPNPARENT, 1);
3094 }
3095
4/4
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3096 {
3097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420 times.
420 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3098 }
3099
4/4
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3100 {
3101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420 times.
420 set_qr(qr_OLDQUESTMISC, 1);
3102 }
3103
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3104 {
3105
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3106
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDEWPNPARENT, 0);
3107
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDQUESTMISC, 0);
3108 282 }
3109
3110 //item scripts continue to run
3111
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3112 {
3113
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3114
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3115
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3116
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3117
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3118
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3119
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3120 282 }
3121
3122
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3123 {
3124
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3125 282 }
3126
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3127 {
3128
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_TRACESCRIPTIDS, 0);
3129
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3130
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3131
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_250DIVISION,1);
3132
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3133
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3134
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_FORCE_INLINE,0);
3135
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BINARY_32BIT,0);
3136
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 274 times.
282 if ( get_qr(qr_SELECTAWPN) )
3137 {
3138
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3139 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3140 //Now they **do**, unless you disable that behaviour.
3141 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3142 //now enable the disable L/R item swap on load.
3143 8 }
3144
3145 282 }
3146
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3147 {
3148 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3149
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3150 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3151 //animations ending earlier than they should.
3152
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3153 //Enemies would ignore solidity on the top half of combos
3154
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3155 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3156
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3157 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3158
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3159 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3160
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3161 282 }
3162
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x255 )
3163 {
3164
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOFFCWAITDRAW, 1);
3165
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOITEMWAITDRAW, 1);
3166
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3167
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3168 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3169 282 }
3170
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3171 {
3172
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3173 282 }
3174
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3175 {
3176
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_OLD_PRINTF_ARGS, 1);
3177 282 }
3178
3179
3180
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3181 {
3182
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_BROKEN_RING_POWER, 1);
3183 282 }
3184
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3185 {
3186
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3187 282 }
3188
5/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✓ Branch 5 taken 44 times.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3189 {
3190
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3191 282 }
3192
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
326 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3193 {
3194 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
326 if(get_qr(qr_SET_XBUTTON_ITEMS))
3196 set_qr(qr_SET_YBUTTON_ITEMS,1);
3197 282 }
3198
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3199 {
3200
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3201 282 }
3202
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3203 {
3204
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_OLD_CHEST_COLLISION,1);
3205 282 }
3206
3207
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3208 {
3209
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3210 282 }
3211 //Sideview spikes in 2.50.0
3212
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
282 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3213 {
3214
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 191 times.
328 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3215 137 }
3216 //more 2.50 fixes -Z
3217
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 210 times.
347 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3218 {
3219
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 79 times.
263 set_qr(qr_MELEEMAGICCOST, 0);
3220
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3221
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_OLDMIRRORCOMBOS, 1);
3222
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENBOOKCOST, 1);
3223
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENCHARINTDRAWING, 1);
3224
3225 224 }
3226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
434 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3227 {
3228 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3229 set_qr(qr_MELEEMAGICCOST, 1);
3230 }
3231
3232
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 411 times.
434 if(tempheader.zelda_version < 0x193)
3233 {
3234
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3235 23 }
3236
3237
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 152 times.
434 if(tempheader.zelda_version < 0x255)
3238 {
3239
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDINFMAGIC, 1);
3240 282 }
3241
3242
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 352 times.
434 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3243 {
3244
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3245 82 }
3246
3247
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
434 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3248 {
3249
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 152 times.
434 set_qr(qr_OLD_F6,1);
3250 282 }
3251
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3252 {
3253
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3254 282 }
3255
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3256 {
3257
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3258 282 }
3259
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3260 {
3261
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 44 times.
326 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3262 282 }
3263 //}
3264
3265
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3266
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3267
3268
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 2) //Old CSet2 Handling
3269
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCS2,1);
3270
3271
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3272
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3273
3274
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3275
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3276
3277
3/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 82 times.
282 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3278
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3279
3280
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3281
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3282
3283
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3284
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3285
3286
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3287
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3288
3289
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 9)
3290 {
3291 //Hardcoded BS Patras
3292
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_BS_PATRA,1);
3293 //Hardcoded Patra Inner Eye offsets
3294
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3295 //Broken 'Big enemy' animation style
3296
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3297 //Broken Attribute 31/32
3298
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3299 282 }
3300
3301
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 10) //Shared candle use limits
3302
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3303
3304
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 11) //No cross-screen return points
3305
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_RESPAWN_POINTS,1);
3306
3307
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 12)
3308 {
3309 //Old fire trail duration
3310
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3311 //Old Intro String in Ganon Room Behavior
3312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3313
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_GANONINTRO,1);
3314 282 }
3315
3316
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
282 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3317 set_qr(qr_ANONE_NOANIM,1);
3318
3319
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 14) //Old Bridge Combo Behavior
3320
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3321
3322
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 15) //Broken Z3 Animation
3323
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3324
3325
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3326
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3327
3328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 17)
3329 {
3330 //Old Quake/DrawYOffset behavior
3331 //set_qr(qr_OLD_DRAWOFFSET,1);
3332 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3333 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3334 282 }
3335
3336
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 18)
3337 {
3338 //Broken DrawScreen Derivative Functions
3339
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3340 //Scrolling Cancels Charge
3341
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3342 282 }
3343
3344
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3345
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3346
3347
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 20)
3348
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3349
3350
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 21)
3351 {
3352
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3353
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3354
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3355
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BUG_NET,1);
3356
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3357 282 }
3358
3359
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 22)
3360
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3361
3362
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 23)
3363
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_HALF_MAGIC,1);
3364
3365
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 24)
3366 {
3367
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3368
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3369 282 }
3370
3371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 25)
3372 {
3373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3374
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3375
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3376 282 }
3377
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 26)
3378 {
3379
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3380
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_POLVIRE_NO_SHADOW,1);
3381
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3382 282 }
3383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3384 {
3385
2/2
✓ Branch 0 taken 84882 times.
✓ Branch 1 taken 282 times.
85164 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3386
1/2
✓ Branch 0 taken 84882 times.
✗ Branch 1 not taken.
84882 set_qr(q,0);
3387
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 282 times.
1974 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3388
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 set_qr(q,0);
3389 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3390 282 }
3391
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
282 if(compatrule_version < 28)
3392
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3393
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 29)
3394
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3395
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 30)
3396 {
3397
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DECO_2_YOFFSET,1);
3398
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCREENSTATE_80s_BUG,1);
3399 287 }
3400
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 31)
3401 {
3402
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3403
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3404 287 }
3405
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 32)
3406
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3407
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 33)
3408
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NO_LIFT_SPRITE,1);
3409
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 34)
3410 {
3411
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3412
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3413
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3414
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3415 287 }
3416
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 35)
3417 {
3418
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3419
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3420 289 }
3421
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 36)
3422
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_OLD_SHALLOW_SFX,1);
3423
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 37)
3424
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3425
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 38)
3426
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3427
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 39)
3428
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3429
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 40)
3430
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3431
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 41)
3432
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKENHITBY,1);
3433
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 42)
3434
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3435
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 43)
3436
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_BOMB_HITBOXES,1);
3437
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 44)
3438
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3439
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 45)
3440
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3441
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 46)
3442
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3443
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 47)
3444 {
3445
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3446
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3447 299 }
3448
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 48)
3449
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GUY_HANDLING,1);
3450
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 49)
3451
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3452
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 50)
3453
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3454
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 51)
3455
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3456
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if (compatrule_version < 52)
3457
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3458
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 53)
3459 {
3460
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SUBSCR,1);
3461
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3462
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3463 299 }
3464
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 54)
3465
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3466
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 55)
3467
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3468
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 56)
3469
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3470
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 57)
3471
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3472
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 58)
3473
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3474
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 59)
3475
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3476
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 60)
3477
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3478
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 61)
3479
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3480
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 62)
3481
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3482
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 63)
3483 {
3484
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_LIFTSWIM,1);
3485
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3486 300 }
3487
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 64)
3488
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3489
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 21 times.
304 if(compatrule_version < 65)
3490
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3491
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 66)
3492
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3493
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 67)
3494
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3495
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 68)
3496
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3497
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 69)
3498
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3499
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 70)
3500
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_CONVEYORS, 1);
3501
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 71)
3502
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3503
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 72)
3504
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3505
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 73)
3506 {
3507
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_LANDING_SFX, 1);
3508
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3509 327 }
3510
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
346 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3511
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3512
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
672 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3513
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3514
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 671 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
998 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3515
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3516
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 77)
3517
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3518
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 78)
3519
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3520
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 79)
3521
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3522
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 80)
3523
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3524
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 991 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1324 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3525
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3526
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1317 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1650 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3527
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3528
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1643 times.
1976 if (compatrule_version < 82)
3529 {
3530
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3531
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3532 333 }
3533
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1643 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1976 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3534
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3535
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1969 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2302 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3536
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3537
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 2294 times.
2628 if (compatrule_version < 85)
3538
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_OLD_WEAPON_REFLECTION, 1);
3539
5/6
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2628 if (compatrule_version < 86 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3540
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 326 times.
18 set_qr(qr_OLD_SPRITE_FALL_DROWN, 1);
3541
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 87)
3542
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_TERMINAL_VELOCITY, 1);
3543
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 88)
3544
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_SCRIPT_LEVEL_GLOBAL_STATES, 1);
3545
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 89)
3546
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_BROKEN_ARMOS_GRAVE_BIGHITBOX_COLLISION, 1);
3547
3548
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 90)
3549 {
3550
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_CLASSIC_DRAWING_ORDER, 1);
3551
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_WEAPON_DRAW_ANIMATE_TIMING, 1);
3552 344 }
3553
3554
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2608 times.
2954 if (compatrule_version < 91)
3555 {
3556
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_INTERNAL_ARRAYS_BOUND_INDEX, 1);
3557
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_ARRAYS_NON_ZERO_DEFAULT_VALUE, 1);
3558 346 }
3559
3560
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2608 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2954 if (compatrule_version < 92 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3561
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 326 times.
20 set_qr(qr_OLD_PIT_SENSITIVITY, 1);
3562
3563
5/6
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 2916 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
3280 if (compatrule_version < 93 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 12) < 0))
3564
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 326 times.
38 set_qr(qr_ACTIVE_SHIELD_PASSIVE_ROC_NO_SCRIPT, 1);
3565
3566
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3242 times.
3606 if (compatrule_version < 94)
3567
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_OLD_SCRIPTS_MESSAGE_DATA_BINARY_ENCODING, 1);
3568
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 3189 times.
3606 if (compatrule_version < 95)
3569
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 set_qr(qr_ONLY_MARK_SCREENS_VISITED_IF_MAP_VIEWABLE, 1);
3570
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 3189 times.
3606 if (compatrule_version < 96)
3571
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 set_qr(qr_ACTIVE_SUB_IGNORE_8PX, 1);
3572
3573
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 3114 times.
3606 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3574
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 210 times.
492 if (s_version < 16)
3575
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3576
3577
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 *Header = tempheader;
3578
3579 492 return 0;
3580 22312 }
3581
3582 4182861 void init_msgstr(MsgStr *str)
3583 {
3584
2/4
✓ Branch 0 taken 4182861 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4182861 times.
4182861 str->setFromLegacyEncoding("");
3585 4182861 str->nextstring=0;
3586 4182861 str->tile=0;
3587 4182861 str->cset=0;
3588 4182861 str->trans=false;
3589 4182861 str->font=font_zfont;
3590 4182861 str->y=32;
3591 4182861 str->sfx=18;
3592 4182861 str->listpos=0;
3593 4182861 str->x=24;
3594 4182861 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3595 4182861 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3596 4182861 str->hspace=0;
3597 4182861 str->vspace=0;
3598 4182861 str->stringflags=0;
3599 4182861 str->margins[up] = 8;
3600 4182861 str->margins[down] = 0;
3601 4182861 str->margins[left] = 8;
3602 4182861 str->margins[right] = 8;
3603 4182861 str->portrait_tile = 0;
3604 4182861 str->portrait_cset = 0;
3605 4182861 str->portrait_x = 0;
3606 4182861 str->portrait_y = 0;
3607 4182861 str->portrait_tw = 1;
3608 4182861 str->portrait_th = 1;
3609 4182861 str->shadow_type = 0;
3610 4182861 str->shadow_color = 0;
3611 4182861 str->drawlayer = 6;
3612 4182861 }
3613
3614 492 void init_msgstrings(int32_t start, int32_t end)
3615 {
3616
2/4
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
492 if(end <= start || end-start > msg_strings_size)
3617 return;
3618
3619
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 4030464 times.
4030956 for(int32_t i=start; i<end; i++)
3620 {
3621 4030464 init_msgstr(&MsgStrings[i]);
3622 4030464 MsgStrings[i].listpos=i;
3623 4030464 }
3624
3625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(start==0)
3626 {
3627
2/4
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
492 MsgStrings[0].setFromLegacyEncoding("(None)");
3628 492 MsgStrings[0].listpos = 0;
3629 492 }
3630 492 }
3631
3632 493 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3633 {
3634
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3635
3636 493 MsgStr tempMsgString;
3637
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 init_msgstr(&tempMsgString);
3638
3639 493 word temp_msg_count=0;
3640 word temp_expansion[16];
3641 493 memset(temp_expansion, 0, 16*sizeof(word));
3642 493 char buf[8193] = {0};
3643
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 469 times.
493 if(Header->zelda_version < 0x193)
3644 {
3645 byte tempbyte;
3646 24 int32_t strings_to_read=0;
3647
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3648
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3649
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3650
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3651 {
3652 18 strings_to_read=128;
3653 18 temp_msg_count=Header->old_str_count;
3654
3655 // Some sort of string count corruption seems to be common in old quests
3656
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3657 {
3658 temp_msg_count=128;
3659 }
3660 18 }
3661
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3662 {
3663 strings_to_read=255;
3664 temp_msg_count=Header->old_str_count;
3665 }
3666 else
3667 {
3668
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3669 {
3670 return qe_invalid;
3671 }
3672
3673 6 strings_to_read=temp_msg_count;
3674
3675
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3676 {
3677 Z_message("Reallocating string buffer...\n");
3678
3679 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3680 // return qe_nomem;
3681
3682 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3683 delete[] MsgStrings;
3684 MsgStrings = new MsgStr[MAXMSGS];
3685 msg_strings_size = MAXMSGS;
3686 for(auto q = 0; q < msg_strings_size; ++q)
3687 {
3688 MsgStrings[q].clear();
3689 }
3690 }
3691 }
3692
3693 //reset the message strings
3694
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3695
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3696
3697
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3698 {
3699
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3700 2550 tempMsgString.listpos = x;
3701
3702
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3703 {
3704 return qe_invalid;
3705 }
3706
3707 2550 buf[74] = '\0';
3708
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3709
3710
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3711 {
3712 return qe_invalid;
3713 }
3714
3715
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3716
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3717 {
3718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3719
3720
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3721 {
3722 return qe_invalid;
3723 }
3724
3725
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3726 {
3727 return qe_invalid;
3728 }
3729 2304 }
3730 else
3731 {
3732
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3733 {
3734 return qe_invalid;
3735 }
3736
3737
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3738 {
3739 return qe_invalid;
3740 }
3741 }
3742
3743
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3744 {
3745
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3746 2549 }
3747 2550 }
3748 24 }
3749 else
3750 {
3751 int32_t dummy_int;
3752 word s_version;
3753
3754 //section version info
3755
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&s_version,f))
3756 {
3757 return qe_invalid;
3758 }
3759
3760
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (s_version > V_STRINGS)
3761 return qe_version;
3762
3763 469 FFCore.quest_format[vStrings] = s_version;
3764
3765
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!read_deprecated_section_cversion(f))
3766 {
3767 return qe_invalid;
3768 }
3769
3770 //section size
3771
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetl(&dummy_int,f))
3772 {
3773 return qe_invalid;
3774 }
3775
3776 //finally... section data
3777
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&temp_msg_count,f))
3778 {
3779 return qe_invalid;
3780 }
3781
3782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
469 if(temp_msg_count >= msg_strings_size && !should_skip)
3783 {
3784 Z_message("Reallocating string buffer...\n");
3785
3786 delete[] MsgStrings;
3787 MsgStrings = new MsgStr[MAXMSGS];
3788 msg_strings_size = MAXMSGS;
3789 for(auto q = 0; q < msg_strings_size; ++q)
3790 {
3791 MsgStrings[q].clear();
3792 }
3793 }
3794
3795 //reset the message strings
3796
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 210 times.
469 if(s_version < 7)
3797
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3798
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (!should_skip)
3799
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 init_msgstrings(0,msg_strings_size);
3800
3801 469 int32_t string_length=(s_version<2)?73:145;
3802
3803
2/2
✓ Branch 0 taken 149354 times.
✓ Branch 1 taken 469 times.
149823 for(int32_t i=0; i<temp_msg_count; i++)
3804 {
3805
1/2
✓ Branch 0 taken 149354 times.
✗ Branch 1 not taken.
149354 init_msgstr(&tempMsgString);
3806
2/2
✓ Branch 0 taken 148249 times.
✓ Branch 1 taken 1105 times.
149354 if (s_version >= 11)
3807 1105 tempMsgString.encoding_type = MsgStr::EncodingType::Ascii;
3808 149354 tempMsgString.listpos = i;
3809
2/2
✓ Branch 0 taken 17428 times.
✓ Branch 1 taken 131926 times.
149354 if(s_version > 8)
3810 {
3811
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_igetl(&string_length,f))
3812 {
3813 return qe_invalid;
3814 }
3815 17428 }
3816
3817
2/4
✓ Branch 0 taken 149354 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 149354 times.
149354 if (string_length < 0 || string_length > 8193)
3818 {
3819 return qe_invalid;
3820 }
3821
3822
2/2
✓ Branch 0 taken 144482 times.
✓ Branch 1 taken 4872 times.
149354 if (string_length > 0)
3823 {
3824
2/4
✓ Branch 0 taken 144482 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144482 times.
✗ Branch 3 not taken.
144482 if (!pfread(buf, string_length, f))
3825 {
3826 return qe_invalid;
3827 }
3828 144482 }
3829 else
3830 {
3831 4872 buf[0] = 0;
3832 }
3833
3834
2/4
✓ Branch 0 taken 149354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149354 times.
✗ Branch 3 not taken.
149354 if(!p_igetw(&tempMsgString.nextstring,f))
3835 {
3836 return qe_invalid;
3837 }
3838
3839
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 115741 times.
149354 if(s_version<2)
3840 {
3841 33613 buf[72] = '\0';
3842
2/4
✓ Branch 0 taken 33613 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33613 times.
✗ Branch 3 not taken.
33613 tempMsgString.setFromLegacyEncoding(buf);
3843 33613 }
3844 else
3845 {
3846 // June 2008: A bug corrupted the last 4 chars of a string.
3847 // Discard these.
3848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115741 times.
115741 if (!should_skip)
3849 {
3850
1/2
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
115741 if(s_version<3)
3851 {
3852 for(int32_t j=140; j<144; j++)
3853 {
3854 buf[j] = '\0';
3855 }
3856 }
3857
1/2
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
115741 if(string_length > 8192) string_length = 8192;
3858 115741 buf[string_length]='\0'; //Force-terminate
3859
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 tempMsgString.set(buf, tempMsgString.encoding_type);
3860 115741 }
3861
3862
2/2
✓ Branch 0 taken 17428 times.
✓ Branch 1 taken 98313 times.
115741 if ( s_version >= 6 )
3863 {
3864
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_igetl(&tempMsgString.tile,f))
3865 {
3866 return qe_invalid;
3867 }
3868 17428 }
3869 else
3870 {
3871
2/4
✓ Branch 0 taken 98313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98313 times.
✗ Branch 3 not taken.
98313 if(!p_igetw(&tempMsgString.tile,f))
3872 {
3873 return qe_invalid;
3874 }
3875 }
3876
3877
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&tempMsgString.cset,f))
3878 {
3879 return qe_invalid;
3880 }
3881
3882 byte dummy_char;
3883
3884
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3885 {
3886 return qe_invalid;
3887 }
3888
3889 115741 tempMsgString.trans=dummy_char!=0;
3890
3891
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&tempMsgString.font,f))
3892 {
3893 return qe_invalid;
3894 }
3895
3896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115741 times.
115741 if(s_version < 5)
3897 {
3898 if(!p_getc(&tempMsgString.y,f))
3899 {
3900 return qe_invalid;
3901 }
3902 }
3903 else
3904 {
3905
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_igetw(&tempMsgString.x,f))
3906 {
3907 return qe_invalid;
3908 }
3909
3910
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_igetw(&tempMsgString.y,f))
3911 {
3912 return qe_invalid;
3913 }
3914
3915
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_igetw(&tempMsgString.w,f))
3916 {
3917 return qe_invalid;
3918 }
3919
3920
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_igetw(&tempMsgString.h,f))
3921 {
3922 return qe_invalid;
3923 }
3924
3925
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&tempMsgString.hspace,f))
3926 {
3927 return qe_invalid;
3928 }
3929
3930
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&tempMsgString.vspace,f))
3931 {
3932 return qe_invalid;
3933 }
3934
3935
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&tempMsgString.stringflags,f))
3936 {
3937 return qe_invalid;
3938 }
3939 }
3940
3941
2/2
✓ Branch 0 taken 98313 times.
✓ Branch 1 taken 17428 times.
115741 if(s_version >= 7)
3942 {
3943
2/2
✓ Branch 0 taken 17428 times.
✓ Branch 1 taken 69712 times.
87140 for(int32_t q = 0; q < 4; ++q)
3944 {
3945
2/4
✓ Branch 0 taken 69712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69712 times.
✗ Branch 3 not taken.
69712 if(!p_getc(&tempMsgString.margins[q],f))
3946 {
3947 return qe_invalid;
3948 }
3949 69712 }
3950
3951
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_igetl(&tempMsgString.portrait_tile,f))
3952 {
3953 return qe_invalid;
3954 }
3955
3956
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.portrait_cset,f))
3957 {
3958 return qe_invalid;
3959 }
3960
3961
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.portrait_x,f))
3962 {
3963 return qe_invalid;
3964 }
3965
3966
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.portrait_y,f))
3967 {
3968 return qe_invalid;
3969 }
3970
3971
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.portrait_tw,f))
3972 {
3973 return qe_invalid;
3974 }
3975
3976
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.portrait_th,f))
3977 {
3978 return qe_invalid;
3979 }
3980 17428 }
3981
3982
2/2
✓ Branch 0 taken 17428 times.
✓ Branch 1 taken 98313 times.
115741 if(s_version >= 8)
3983 {
3984
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.shadow_type,f))
3985 {
3986 return qe_invalid;
3987 }
3988
3989
2/4
✓ Branch 0 taken 17428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17428 times.
✗ Branch 3 not taken.
17428 if(!p_getc(&tempMsgString.shadow_color,f))
3990 {
3991 return qe_invalid;
3992 }
3993 17428 }
3994
3995
2/2
✓ Branch 0 taken 17119 times.
✓ Branch 1 taken 98622 times.
115741 if(s_version >= 10)
3996 {
3997
2/4
✓ Branch 0 taken 17119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17119 times.
✗ Branch 3 not taken.
17119 if(!p_getc(&tempMsgString.drawlayer,f))
3998 {
3999 return qe_invalid;
4000 }
4001 17119 }
4002
4003
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_getc(&tempMsgString.sfx,f))
4004 {
4005 return qe_invalid;
4006 }
4007
4008
1/2
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
115741 if(s_version>3)
4009 {
4010
2/4
✓ Branch 0 taken 115741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115741 times.
✗ Branch 3 not taken.
115741 if(!p_igetw(&tempMsgString.listpos,f))
4011 {
4012 return qe_invalid;
4013 }
4014 115741 }
4015 }
4016
4017
1/2
✓ Branch 0 taken 149354 times.
✗ Branch 1 not taken.
149354 if (!should_skip)
4018 {
4019
1/2
✓ Branch 0 taken 149354 times.
✗ Branch 1 not taken.
149354 MsgStrings[i].copyAll(tempMsgString);
4020 149354 }
4021 149354 }
4022 }
4023
4024
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 492 times.
493 if (!should_skip)
4025 492 msg_count=temp_msg_count;
4026
4027 493 return 0;
4028 493 }
4029
4030 493 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4031 {
4032
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4033
4034
3/4
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
499 if((Header->zelda_version < 0x192)||
4035
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 469 times.
475 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4036 {
4037 18 return 0;
4038 }
4039
4040 475 word temp_door_combo_set_count=0;
4041 DoorComboSet tempDoorComboSet;
4042 word dummy_word;
4043 int32_t dummy_long;
4044 byte padding;
4045 475 int32_t s_version = 0;
4046
4047
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 474 times.
475 if (!should_skip)
4048 {
4049 474 DoorComboSets = {};
4050 474 DoorComboSetNames = {};
4051 474 }
4052
4053
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 469 times.
475 if(Header->zelda_version > 0x192)
4054 {
4055 //section version info
4056
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&s_version,f))
4057 {
4058 return qe_invalid;
4059 }
4060
4061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (s_version > V_DOORS)
4062 return qe_version;
4063
4064 469 FFCore.quest_format[vDoors] = s_version;
4065
4066
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&dummy_word,f))
4067 {
4068 return qe_invalid;
4069 }
4070
4071 //section size
4072
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy_long,f))
4073 {
4074 return qe_invalid;
4075 }
4076 469 }
4077
4078 //finally... section data
4079
1/2
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
475 if(!p_igetw(&temp_door_combo_set_count,f))
4080 {
4081 return qe_invalid;
4082 }
4083
4084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4085 {
4086 return qe_invalid;
4087 }
4088
4089
2/2
✓ Branch 0 taken 5683 times.
✓ Branch 1 taken 475 times.
6158 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4090 {
4091 5683 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4092
4093 //name
4094 char name[21];
4095
1/2
✓ Branch 0 taken 5683 times.
✗ Branch 1 not taken.
5683 if(!pfread(&name,sizeof(name),f))
4096 {
4097 return qe_invalid;
4098 }
4099
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5669 times.
5683 if (!should_skip)
4100 5669 DoorComboSetNames[i] = name;
4101
4102
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 40 times.
5683 if(Header->zelda_version < 0x193)
4103 {
4104
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4105 {
4106 return qe_invalid;
4107 }
4108 40 }
4109
4110 //up door
4111
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4112 {
4113
2/2
✓ Branch 0 taken 204588 times.
✓ Branch 1 taken 51147 times.
255735 for(int32_t k=0; k<4; k++)
4114 {
4115
1/2
✓ Branch 0 taken 204588 times.
✗ Branch 1 not taken.
204588 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4116 {
4117 return qe_invalid;
4118 }
4119 204588 }
4120 51147 }
4121
4122
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4123 {
4124
2/2
✓ Branch 0 taken 204588 times.
✓ Branch 1 taken 51147 times.
255735 for(int32_t k=0; k<4; k++)
4125 {
4126
1/2
✓ Branch 0 taken 204588 times.
✗ Branch 1 not taken.
204588 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4127 {
4128 return qe_invalid;
4129 }
4130 204588 }
4131 51147 }
4132
4133 //down door
4134
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4135 {
4136
2/2
✓ Branch 0 taken 204588 times.
✓ Branch 1 taken 51147 times.
255735 for(int32_t k=0; k<4; k++)
4137 {
4138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204588 times.
204588 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4139 {
4140 return qe_invalid;
4141 }
4142 204588 }
4143 51147 }
4144
4145
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4146 {
4147
2/2
✓ Branch 0 taken 204588 times.
✓ Branch 1 taken 51147 times.
255735 for(int32_t k=0; k<4; k++)
4148 {
4149
1/2
✓ Branch 0 taken 204588 times.
✗ Branch 1 not taken.
204588 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4150 {
4151 return qe_invalid;
4152 }
4153 204588 }
4154 51147 }
4155
4156 //left door
4157
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4158 {
4159
2/2
✓ Branch 0 taken 306882 times.
✓ Branch 1 taken 51147 times.
358029 for(int32_t k=0; k<6; k++)
4160 {
4161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306882 times.
306882 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4162 {
4163 return qe_invalid;
4164 }
4165 306882 }
4166 51147 }
4167
4168
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4169 {
4170
2/2
✓ Branch 0 taken 306882 times.
✓ Branch 1 taken 51147 times.
358029 for(int32_t k=0; k<6; k++)
4171 {
4172
1/2
✓ Branch 0 taken 306882 times.
✗ Branch 1 not taken.
306882 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4173 {
4174 return qe_invalid;
4175 }
4176 306882 }
4177 51147 }
4178
4179 //right door
4180
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4181 {
4182
2/2
✓ Branch 0 taken 306882 times.
✓ Branch 1 taken 51147 times.
358029 for(int32_t k=0; k<6; k++)
4183 {
4184
1/2
✓ Branch 0 taken 306882 times.
✗ Branch 1 not taken.
306882 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4185 {
4186 return qe_invalid;
4187 }
4188 306882 }
4189 51147 }
4190
4191
2/2
✓ Branch 0 taken 51147 times.
✓ Branch 1 taken 5683 times.
56830 for(int32_t j=0; j<9; j++)
4192 {
4193
2/2
✓ Branch 0 taken 306882 times.
✓ Branch 1 taken 51147 times.
358029 for(int32_t k=0; k<6; k++)
4194 {
4195
1/2
✓ Branch 0 taken 306882 times.
✗ Branch 1 not taken.
306882 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4196 {
4197 return qe_invalid;
4198 }
4199 306882 }
4200 51147 }
4201
4202 //up bomb rubble
4203
2/2
✓ Branch 0 taken 11366 times.
✓ Branch 1 taken 5683 times.
17049 for(int32_t j=0; j<2; j++)
4204 {
4205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11366 times.
11366 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4206 {
4207 return qe_invalid;
4208 }
4209 11366 }
4210
4211
2/2
✓ Branch 0 taken 11366 times.
✓ Branch 1 taken 5683 times.
17049 for(int32_t j=0; j<2; j++)
4212 {
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11366 times.
11366 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4214 {
4215 return qe_invalid;
4216 }
4217 11366 }
4218
4219 //down bomb rubble
4220
2/2
✓ Branch 0 taken 11366 times.
✓ Branch 1 taken 5683 times.
17049 for(int32_t j=0; j<2; j++)
4221 {
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11366 times.
11366 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4223 {
4224 return qe_invalid;
4225 }
4226 11366 }
4227
4228
2/2
✓ Branch 0 taken 11366 times.
✓ Branch 1 taken 5683 times.
17049 for(int32_t j=0; j<2; j++)
4229 {
4230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11366 times.
11366 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4231 {
4232 return qe_invalid;
4233 }
4234 11366 }
4235
4236 //left bomb rubble
4237
2/2
✓ Branch 0 taken 17049 times.
✓ Branch 1 taken 5683 times.
22732 for(int32_t j=0; j<3; j++)
4238 {
4239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17049 times.
17049 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4240 {
4241 return qe_invalid;
4242 }
4243 17049 }
4244
4245
2/2
✓ Branch 0 taken 17049 times.
✓ Branch 1 taken 5683 times.
22732 for(int32_t j=0; j<3; j++)
4246 {
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17049 times.
17049 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4248 {
4249 return qe_invalid;
4250 }
4251 17049 }
4252
4253
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 40 times.
5683 if(Header->zelda_version < 0x193)
4254 {
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4256 {
4257 return qe_invalid;
4258 }
4259
4260 40 }
4261
4262 //right bomb rubble
4263
2/2
✓ Branch 0 taken 17049 times.
✓ Branch 1 taken 5683 times.
22732 for(int32_t j=0; j<3; j++)
4264 {
4265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17049 times.
17049 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4266 {
4267 return qe_invalid;
4268 }
4269 17049 }
4270
4271
2/2
✓ Branch 0 taken 17049 times.
✓ Branch 1 taken 5683 times.
22732 for(int32_t j=0; j<3; j++)
4272 {
4273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17049 times.
17049 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4274 {
4275 return qe_invalid;
4276 }
4277 17049 }
4278
4279
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 40 times.
5683 if(Header->zelda_version < 0x193)
4280 {
4281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4282 {
4283 return qe_invalid;
4284 }
4285 40 }
4286
4287 //walkthrough stuff
4288
2/2
✓ Branch 0 taken 22732 times.
✓ Branch 1 taken 5683 times.
28415 for(int32_t j=0; j<4; j++)
4289 {
4290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22732 times.
22732 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4291 {
4292 return qe_invalid;
4293 }
4294 22732 }
4295
4296
2/2
✓ Branch 0 taken 22732 times.
✓ Branch 1 taken 5683 times.
28415 for(int32_t j=0; j<4; j++)
4297 {
4298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22732 times.
22732 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4299 {
4300 return qe_invalid;
4301 }
4302 22732 }
4303
4304 //flags
4305
2/2
✓ Branch 0 taken 11366 times.
✓ Branch 1 taken 5683 times.
17049 for(int32_t j=0; j<2; j++)
4306 {
4307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11366 times.
11366 if(!p_getc(&tempDoorComboSet.flags[j],f))
4308 {
4309 return qe_invalid;
4310 }
4311 11366 }
4312
4313
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 40 times.
5683 if(Header->zelda_version < 0x193)
4314 {
4315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4316 {
4317 return qe_invalid;
4318 }
4319 40 }
4320
4321
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5669 times.
5683 if (!should_skip)
4322 5669 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4323 5683 }
4324
4325
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 474 times.
475 if (!should_skip)
4326 474 door_combo_set_count=temp_door_combo_set_count;
4327
4328 475 return 0;
4329 493 }
4330
4331 9 int32_t count_dmaps()
4332 {
4333 9 int32_t i=MAXDMAPS-1;
4334 9 bool found=false;
4335
4336
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4337 {
4338
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4339
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4340
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4341 18 found=true;
4342
4343
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4344 {
4345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4346
4347 found=true;
4348 72 }
4349
4350
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4351 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4352 27 found=true;
4353
4354
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4355
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4356
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4357
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4358 18 found=true;
4359
4360 if(!found)
4361 {
4362 i--;
4363 }
4364 }
4365
4366 9 return i+1;
4367 }
4368
4369
4370 9 int32_t count_shops(miscQdata *Misc)
4371 {
4372 9 int32_t i=NUM_SHOPS-1,j;
4373 9 bool found=false;
4374
4375
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4376 {
4377 2229 j=2;
4378
4379
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4380 {
4381
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4382 {
4383 5 found=true;
4384 5 }
4385 else
4386 {
4387 6672 j--;
4388 }
4389 }
4390
4391
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4392 {
4393 found=true;
4394 }
4395
4396
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4397 {
4398 2224 i--;
4399 2224 }
4400 }
4401
4402 9 return i+1;
4403 }
4404
4405 9 int32_t count_infos(miscQdata *Misc)
4406 {
4407 9 int32_t i=255,j;
4408 9 bool found=false;
4409
4410
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4411 {
4412 2229 j=2;
4413
4414
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4415 {
4416
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4417 {
4418 5 found=true;
4419 5 }
4420 else
4421 {
4422 6672 j--;
4423 }
4424 }
4425
4426
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4427 {
4428 found=true;
4429 }
4430
4431
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4432 {
4433 2224 i--;
4434 2224 }
4435 }
4436
4437 9 return i+1;
4438 }
4439
4440 9 int32_t count_warprings(miscQdata *Misc)
4441 {
4442 9 int32_t i=15,j;
4443 9 bool found=false;
4444
4445
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4446 {
4447 49 j=7;
4448
4449
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4450 {
4451
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4452 {
4453 9 found=true;
4454 9 }
4455 else
4456 {
4457 349 j--;
4458 }
4459 }
4460
4461
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4462 {
4463 40 i--;
4464 40 }
4465 }
4466
4467 9 return i+1;
4468 }
4469
4470 9 int32_t count_palcycles(miscQdata *Misc)
4471 {
4472 9 int32_t i=255,j;
4473 9 bool found=false;
4474
4475
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4476 {
4477 2036 j=2;
4478
4479
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4480 {
4481
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4482 {
4483 7 found=true;
4484 7 }
4485 else
4486 {
4487 6087 j--;
4488 }
4489 }
4490
4491
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4492 {
4493 2029 i--;
4494 2029 }
4495 }
4496
4497 9 return i+1;
4498 }
4499
4500 192168 void clear_screen(mapscr *temp_scr)
4501 {
4502 192168 temp_scr->zero_memory();
4503 192168 }
4504
4505 // NOTE: when modifying this, you need to also update:
4506 // readonedmap, readdmaps, and FFScript::read_dmaps
4507 // (and their associated write functions)
4508 3565 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4509 {
4510
2/2
✓ Branch 0 taken 3541 times.
✓ Branch 1 taken 24 times.
3565 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4511
4512 3565 word dmapstoread=0;
4513 3565 dmap tempDMap;
4514
4515 int32_t dummy;
4516 3565 word s_version=0;
4517 byte padding;
4518
4519 char legacy_title[22];
4520
4521
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 492 times.
3565 if (!should_skip)
4522
2/2
✓ Branch 0 taken 251904 times.
✓ Branch 1 taken 492 times.
252396 for(int32_t i=0; i<max_dmaps; i++)
4523 {
4524
1/2
✓ Branch 0 taken 251904 times.
✗ Branch 1 not taken.
251904 DMaps[start_dmap + i].clear();
4525 251904 sprintf(legacy_title," ");
4526 251904 sprintf(DMaps[start_dmap+i].intro," ");
4527 251904 DMaps[start_dmap+i].type |= dmCAVE;
4528 252396 }
4529
4530
3/4
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 492 times.
✗ Branch 3 not taken.
3565 if (!should_skip && s_version == 21)
4531 Regions = {};
4532
4533 3565 Header->is_z3 = false;
4534
4/4
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 24 times.
3565 if(!Header || Header->zelda_version > 0x192)
4535 {
4536 //section version info
4537
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
3541 if(!p_igetw(&s_version,f))
4538 {
4539 return qe_invalid;
4540 }
4541
4542
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (s_version > V_DMAPS)
4543 return qe_version;
4544
4545 469 Header->is_z3 = s_version >= 22;
4546 469 FFCore.quest_format[vDMaps] = s_version;
4547
4548
4549
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!read_deprecated_section_cversion(f))
4550 {
4551 return qe_invalid;
4552 }
4553
4554 //section size
4555
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetl(&dummy,f))
4556 {
4557 return qe_invalid;
4558 }
4559
4560 //finally... section data
4561
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&dmapstoread,f))
4562 {
4563 return qe_invalid;
4564 }
4565 469 }
4566 else
4567 {
4568
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4569
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4570 {
4571 18 dmapstoread=32;
4572 18 }
4573
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4574 {
4575 6 dmapstoread=OLDMAXDMAPS;
4576 6 }
4577 else
4578 {
4579 dmapstoread=MAXDMAPS;
4580 }
4581 }
4582
4583
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 410 times.
493 dmapstoread=zc_min(dmapstoread, max_dmaps);
4584
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 410 times.
493 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4585
4586
2/2
✓ Branch 0 taken 227136 times.
✓ Branch 1 taken 493 times.
227629 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4587 {
4588
1/2
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
227136 tempDMap.clear();
4589 227136 sprintf(legacy_title," ");
4590 227136 sprintf(tempDMap.intro," ");
4591
4592
2/4
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227136 times.
✗ Branch 3 not taken.
227136 if(!p_getc(&tempDMap.map,f))
4593 {
4594 return qe_invalid;
4595 }
4596
4597
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 209920 times.
227136 if(s_version <= 4)
4598 {
4599 byte tempbyte;
4600
4601
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4602 {
4603 return qe_invalid;
4604 }
4605
4606 17216 tempDMap.level=(word)tempbyte;
4607 17216 }
4608 else
4609 {
4610
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!p_igetw(&tempDMap.level,f))
4611 {
4612 return qe_invalid;
4613 }
4614 }
4615
4616
2/4
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227136 times.
✗ Branch 3 not taken.
227136 if(!p_getc(&tempDMap.xoff,f))
4617 {
4618 return qe_invalid;
4619 }
4620
4621
2/4
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227136 times.
✗ Branch 3 not taken.
227136 if(!p_getc(&tempDMap.compass,f))
4622 {
4623 return qe_invalid;
4624 }
4625
4626
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 17216 times.
227136 if(s_version > 8) // February 2009
4627 {
4628
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!p_igetw(&tempDMap.color,f))
4629 {
4630 return qe_invalid;
4631 }
4632 209920 }
4633 else
4634 {
4635 byte tempbyte;
4636
4637
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4638 {
4639 return qe_invalid;
4640 }
4641
4642 17216 tempDMap.color = (word)tempbyte;
4643 }
4644
4645
2/4
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227136 times.
✗ Branch 3 not taken.
227136 if(!p_getc(&tempDMap.midi,f))
4646 {
4647 return qe_invalid;
4648 }
4649
4650
2/4
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227136 times.
✗ Branch 3 not taken.
227136 if(!p_getc(&tempDMap.cont,f))
4651 {
4652 return qe_invalid;
4653 }
4654
4655
2/4
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227136 times.
✗ Branch 3 not taken.
227136 if(!p_getc(&tempDMap.type,f))
4656 {
4657 return qe_invalid;
4658 }
4659
4660
4/4
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 220799 times.
✓ Branch 2 taken 6293 times.
✓ Branch 3 taken 44 times.
233473 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4661
1/2
✓ Branch 0 taken 6337 times.
✗ Branch 1 not taken.
6337 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4662 6293 tempDMap.xoff = 0;
4663
4664
2/2
✓ Branch 0 taken 227136 times.
✓ Branch 1 taken 1817088 times.
2044224 for(int32_t j=0; j<8; j++)
4665 {
4666
2/4
✓ Branch 0 taken 1817088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1817088 times.
✗ Branch 3 not taken.
1817088 if(!p_getc(&tempDMap.grid[j],f))
4667 {
4668 return qe_invalid;
4669 }
4670 1817088 }
4671
4672
5/6
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 225024 times.
227136 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4673 {
4674
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4675 {
4676 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4677 127 }
4678
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4679
4680
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4681 {
4682
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4683
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4684 18 }
4685
4686 //forgotten -DD
4687
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4688 {
4689 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4690 439 }
4691 576 }
4692 else
4693 {
4694
3/4
✓ Branch 0 taken 226560 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
225024 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4695 {
4696 return qe_invalid;
4697 }
4698
4699
2/2
✓ Branch 0 taken 127744 times.
✓ Branch 1 taken 98816 times.
226560 if(s_version<20)
4700 {
4701
2/4
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127744 times.
✗ Branch 3 not taken.
127744 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4702 {
4703 return qe_invalid;
4704 }
4705
1/2
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
127744 tempDMap.title.assign(legacy_title);
4706 127744 }
4707 else
4708 {
4709
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if (!p_getwstr(&tempDMap.title, f))
4710 {
4711 return qe_invalid;
4712 }
4713 }
4714
4715
2/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
226560 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4716 {
4717 return qe_invalid;
4718 }
4719
4720
5/8
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 225024 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
226560 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4721 {
4722 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4723 DMaps[i] = tempDMap;
4724
4725 continue;
4726 }
4727
4728
3/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 225024 times.
226560 if(Header && (Header->zelda_version < 0x193))
4729 {
4730
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4731 {
4732 return qe_invalid;
4733 }
4734 1536 }
4735
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119040 times.
226560 if ( s_version >= 11 )
4736 {
4737
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4738 {
4739 return qe_invalid;
4740 }
4741 107520 }
4742 else
4743 {
4744
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4745 {
4746 return qe_invalid;
4747 }
4748 }
4749
4750
2/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
226560 if(!p_getc(&tempDMap.minimap_cset[0],f))
4751 {
4752 return qe_invalid;
4753 }
4754
4755
3/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 225024 times.
226560 if(Header && (Header->zelda_version < 0x193))
4756 {
4757
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4758 {
4759 return qe_invalid;
4760 }
4761 1536 }
4762
4763
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119040 times.
226560 if ( s_version >= 11 )
4764 {
4765
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4766 {
4767 return qe_invalid;
4768 }
4769 107520 }
4770 else
4771 {
4772
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4773 {
4774 return qe_invalid;
4775 }
4776 }
4777
2/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
226560 if(!p_getc(&tempDMap.minimap_cset[1],f))
4778 {
4779 return qe_invalid;
4780 }
4781
4782
3/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 225024 times.
226560 if(Header && (Header->zelda_version < 0x193))
4783 {
4784
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4785 {
4786 return qe_invalid;
4787 }
4788 1536 }
4789
4790
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119040 times.
226560 if ( s_version >= 11 )
4791 {
4792
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4793 {
4794 return qe_invalid;
4795 }
4796 107520 }
4797 else
4798 {
4799
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4800 {
4801 return qe_invalid;
4802 }
4803 }
4804
4805
2/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
226560 if(!p_getc(&tempDMap.largemap_cset[0],f))
4806 {
4807 return qe_invalid;
4808 }
4809
4810
3/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 225024 times.
226560 if(Header && (Header->zelda_version < 0x193))
4811 {
4812
4813
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4814 {
4815 return qe_invalid;
4816 }
4817 1536 }
4818
4819
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119040 times.
226560 if ( s_version >= 11 )
4820 {
4821
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4822 {
4823 return qe_invalid;
4824 }
4825 107520 }
4826 else
4827 {
4828
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4829 {
4830 return qe_invalid;
4831 }
4832 }
4833
2/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
226560 if(!p_getc(&tempDMap.largemap_cset[1],f))
4834 {
4835 return qe_invalid;
4836 }
4837
4838
2/4
✓ Branch 0 taken 226560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226560 times.
✗ Branch 3 not taken.
226560 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4839 {
4840 return qe_invalid;
4841 }
4842 }
4843
4844
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 17216 times.
227136 if(s_version>1)
4845 {
4846
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!p_getc(&tempDMap.tmusictrack,f))
4847 {
4848 return qe_invalid;
4849 }
4850
4851
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!p_getc(&tempDMap.active_subscreen,f))
4852 {
4853 return qe_invalid;
4854 }
4855
4856
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!p_getc(&tempDMap.passive_subscreen,f))
4857 {
4858 return qe_invalid;
4859 }
4860 209920 }
4861
4862
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 17216 times.
227136 if(s_version>2)
4863 {
4864 byte di[32];
4865
4866
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!pfread(&di, 32, f)) return qe_invalid;
4867
4868
2/2
✓ Branch 0 taken 53739520 times.
✓ Branch 1 taken 209920 times.
53949440 for(int32_t j=0; j<MAXITEMS; j++)
4869 {
4870
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 53730313 times.
53739520 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4871 53730313 else tempDMap.disableditems[j]=0;
4872 53739520 }
4873 209920 }
4874
4875
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 17216 times.
227136 if(s_version >= 6)
4876 {
4877
2/4
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209920 times.
✗ Branch 3 not taken.
209920 if(!p_igetl(&tempDMap.flags,f))
4878 {
4879 return qe_invalid;
4880 }
4881 209920 }
4882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4883 {
4884 char temp;
4885
4886 if(!p_getc(&temp,f))
4887 {
4888 return qe_invalid;
4889 }
4890
4891 tempDMap.flags = temp;
4892 }
4893
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4894 {
4895 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4896 8992 }
4897 else
4898 8224 tempDMap.flags=0;
4899
4900
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 17216 times.
227136 if(s_version<7)
4901 {
4902
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4903 6146 tempDMap.flags|= dmfVIEWMAP;
4904 17216 }
4905
4906
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 17216 times.
227136 if(s_version<8)
4907 {
4908
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4909 {
4910
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4911 8050 tempDMap.type |= dmCAVE;
4912 8050 }
4913
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4914 {
4915 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4916 2332 }
4917 17216 }
4918
4919
7/8
✓ Branch 0 taken 227136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 225024 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 225024 times.
227136 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4920 226560 && (Header->zelda_version < 0x193))
4921 {
4922
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4923 {
4924 return qe_invalid;
4925 }
4926 1536 }
4927
4928
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 107520 times.
227136 if(s_version >= 10)
4929 {
4930
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_getc(&tempDMap.sideview,f))
4931 {
4932 return qe_invalid;
4933 }
4934 107520 }
4935
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if(s_version < 10) tempDMap.sideview = 0;
4936
4937 //Dmap Scripts
4938
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if(s_version >= 12)
4939 {
4940
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetw(&tempDMap.script,f))
4941 {
4942 return qe_invalid;
4943 }
4944
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for ( int32_t q = 0; q < 8; q++ )
4945 {
4946
2/4
✓ Branch 0 taken 860160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860160 times.
✗ Branch 3 not taken.
860160 if(!p_igetl(&tempDMap.initD[q],f))
4947 {
4948 return qe_invalid;
4949 }
4950 860160 }
4951 107520 }
4952
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if ( s_version < 12 )
4953 {
4954 119616 tempDMap.script = 0;
4955
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4956 {
4957 956928 tempDMap.initD[q] = 0;
4958 956928 }
4959 119616 }
4960
4961
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 107520 times.
227136 if(s_version >= 13)
4962 {
4963
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for ( int32_t q = 0; q < 8; q++ )
4964 {
4965
2/2
✓ Branch 0 taken 55910400 times.
✓ Branch 1 taken 860160 times.
56770560 for ( int32_t w = 0; w < 65; w++ )
4966 {
4967
2/4
✓ Branch 0 taken 55910400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55910400 times.
✗ Branch 3 not taken.
55910400 if(!p_getc(&tempDMap.initD_label[q][w],f))
4968 {
4969 return qe_invalid;
4970 }
4971 55910400 }
4972 860160 }
4973 107520 }
4974
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if ( s_version < 13 )
4975 {
4976 119616 tempDMap.script = 0;
4977
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4978 {
4979
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for ( int32_t w = 0; w < 65; w++ )
4980 62200320 tempDMap.initD_label[q][w] = 0;
4981 956928 }
4982 119616 }
4983
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if(s_version >= 14)
4984 {
4985
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetw(&tempDMap.active_sub_script,f))
4986 {
4987 return qe_invalid;
4988 }
4989
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetw(&tempDMap.passive_sub_script,f))
4990 {
4991 return qe_invalid;
4992 }
4993
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for ( int32_t q = 0; q < 8; ++q )
4994 {
4995
2/4
✓ Branch 0 taken 860160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860160 times.
✗ Branch 3 not taken.
860160 if(!p_igetl(&tempDMap.sub_initD[q],f))
4996 {
4997 return qe_invalid;
4998 }
4999 860160 }
5000
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for(int32_t q = 0; q < 8; ++q)
5001 {
5002
2/2
✓ Branch 0 taken 55910400 times.
✓ Branch 1 taken 860160 times.
56770560 for ( int32_t w = 0; w < 65; ++w )
5003 {
5004
2/4
✓ Branch 0 taken 55910400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55910400 times.
✗ Branch 3 not taken.
55910400 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5005 {
5006 return qe_invalid;
5007 }
5008 55910400 }
5009 860160 }
5010 107520 }
5011 else
5012 {
5013 119616 tempDMap.active_sub_script = 0;
5014 119616 tempDMap.passive_sub_script = 0;
5015
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
5016 {
5017 956928 tempDMap.sub_initD[q] = 0;
5018
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5019 62200320 tempDMap.sub_initD_label[q][w] = 0;
5020 956928 }
5021 }
5022
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if(s_version >= 15)
5023 {
5024
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetw(&tempDMap.onmap_script,f))
5025 {
5026 return qe_invalid;
5027 }
5028
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for ( int32_t q = 0; q < 8; ++q )
5029 {
5030
2/4
✓ Branch 0 taken 860160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860160 times.
✗ Branch 3 not taken.
860160 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5031 {
5032 return qe_invalid;
5033 }
5034 860160 }
5035
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for(int32_t q = 0; q < 8; ++q)
5036 {
5037
2/2
✓ Branch 0 taken 55910400 times.
✓ Branch 1 taken 860160 times.
56770560 for ( int32_t w = 0; w < 65; ++w )
5038 {
5039
2/4
✓ Branch 0 taken 55910400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55910400 times.
✗ Branch 3 not taken.
55910400 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5040 {
5041 return qe_invalid;
5042 }
5043 55910400 }
5044 860160 }
5045 107520 }
5046 else
5047 {
5048 119616 tempDMap.onmap_script = 0;
5049
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
5050 {
5051 956928 tempDMap.onmap_initD[q] = 0;
5052
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5053 {
5054 62200320 tempDMap.onmap_initD_label[q][w] = 0;
5055 62200320 }
5056 956928 }
5057 }
5058
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 119616 times.
227136 if(s_version >= 16)
5059 {
5060
2/4
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
107520 if(!p_igetw(&tempDMap.mirrorDMap,f))
5061 {
5062 return qe_invalid;
5063 }
5064 107520 }
5065 else
5066 {
5067 119616 tempDMap.mirrorDMap = -1;
5068 }
5069
5070 // Enhanced music loop points
5071
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 128320 times.
227136 if (s_version >= 18)
5072 {
5073
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5074 {
5075 return qe_invalid;
5076 }
5077
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5078 {
5079 return qe_invalid;
5080 }
5081
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5082 {
5083 return qe_invalid;
5084 }
5085
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5086 {
5087 return qe_invalid;
5088 }
5089 98816 }
5090 else
5091 {
5092 128320 tempDMap.tmusic_loop_start = 0;
5093 128320 tempDMap.tmusic_loop_end = 0;
5094 128320 tempDMap.tmusic_xfade_in = 0;
5095 128320 tempDMap.tmusic_xfade_out = 0;
5096 }
5097
5098
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 128320 times.
227136 if(s_version >= 19)
5099
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if(!p_getc(&tempDMap.overlay_subscreen, f))
5100 return qe_invalid;
5101
5102
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 128320 times.
227136 if (s_version >= 20)
5103 {
5104
2/4
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98816 times.
✗ Branch 3 not taken.
98816 if (!p_igetl(&tempDMap.intro_string_id, f))
5105 return qe_invalid;
5106 98816 }
5107 else
5108 128320 tempDMap.intro_string_id = 0;
5109
5110
2/2
✓ Branch 0 taken 212800 times.
✓ Branch 1 taken 14336 times.
227136 if(s_version == 21)
5111 {
5112 static regions_data tmp_rd;
5113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5114
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5115 {
5116
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5117 {
5118
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5119 {
5120 return qe_invalid;
5121 }
5122 917504 }
5123 114688 }
5124 14336 }
5125
5126
3/4
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 151360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75776 times.
227136 if (s_version > 22 && (tempDMap.flags & dmfCUSTOM_GRAVITY))
5127 {
5128 if (!p_igetzf(&tempDMap.dmap_gravity, f))
5129 return qe_invalid;
5130 if (!p_igetzf(&tempDMap.dmap_terminal_v, f))
5131 return qe_invalid;
5132 }
5133
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 188736 times.
227136 if(s_version > 23)
5134 {
5135
2/4
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38400 times.
✗ Branch 3 not taken.
38400 if(!p_igetw(&tempDMap.map_subscreen, f))
5136 return qe_invalid;
5137
2/4
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38400 times.
✗ Branch 3 not taken.
38400 if(!p_getc(&tempDMap.floor, f))
5138 return qe_invalid;
5139 38400 }
5140
5141
2/2
✓ Branch 0 taken 226880 times.
✓ Branch 1 taken 256 times.
227136 if (!should_skip)
5142 {
5143
1/2
✓ Branch 0 taken 226880 times.
✗ Branch 1 not taken.
226880 if(loading_tileset_flags & TILESET_CLEARMAPS)
5144 tempDMap.map = 0;
5145
1/2
✓ Branch 0 taken 226880 times.
✗ Branch 1 not taken.
226880 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5146 {
5147 tempDMap.script = 0;
5148 for(int q = 0; q < 8; ++q)
5149 tempDMap.initD[q] = 0;
5150 }
5151
1/2
✓ Branch 0 taken 226880 times.
✗ Branch 1 not taken.
226880 DMaps[i] = tempDMap;
5152 226880 }
5153 227136 }
5154
5155 493 return 0;
5156 6637 }
5157
5158 410 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5159 {
5160 //these are here to bypass compiler warnings about unused arguments
5161 410 Header=Header;
5162
5163 miscQdata temp_misc;
5164 410 word s_version=0;
5165 410 int32_t tempsize=0;
5166 word dummyw;
5167
5168 410 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5169
5170 //section version info
5171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(!p_igetw(&s_version,f))
5172 {
5173 return qe_invalid;
5174 }
5175
5176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_COLORS)
5177 return qe_version;
5178
5179 410 FFCore.quest_format[vColours] = s_version;
5180
5181 410 al_trace("Misc Colours section version: %d\n", s_version);
5182
5183
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
5184 {
5185 return qe_invalid;
5186 }
5187
5188
5189 //section size
5190
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&tempsize,f))
5191 {
5192 return qe_invalid;
5193 }
5194
5195 //finally... section data
5196 410 readsize=0;
5197
5198
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.text,f))
5199 {
5200 return qe_invalid;
5201 }
5202
5203
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.caption,f))
5204 {
5205 return qe_invalid;
5206 }
5207
5208
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.overw_bg,f))
5209 {
5210 return qe_invalid;
5211 }
5212
5213
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5214 {
5215 return qe_invalid;
5216 }
5217
5218
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5219 {
5220 return qe_invalid;
5221 }
5222
5223
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.cave_fg,f))
5224 {
5225 return qe_invalid;
5226 }
5227
5228
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.bs_dk,f))
5229 {
5230 return qe_invalid;
5231 }
5232
5233
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.bs_goal,f))
5234 {
5235 return qe_invalid;
5236 }
5237
5238
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.compass_lt,f))
5239 {
5240 return qe_invalid;
5241 }
5242
5243
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.compass_dk,f))
5244 {
5245 return qe_invalid;
5246 }
5247
5248
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5249 {
5250 return qe_invalid;
5251 }
5252
5253
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.triframe_color,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.hero_dot,f))
5259 {
5260 return qe_invalid;
5261 }
5262
5263
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5264 {
5265 return qe_invalid;
5266 }
5267
5268
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5269 {
5270 return qe_invalid;
5271 }
5272
5273
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5274 {
5275 return qe_invalid;
5276 }
5277
5278
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5294 {
5295 return qe_invalid;
5296 }
5297
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if(s_version < 4)
5298 {
5299
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5300 return qe_invalid;
5301 200 temp_misc.colors.triforce_tile = dummyw;
5302
5303
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5304 return qe_invalid;
5305 200 temp_misc.colors.triframe_tile = dummyw;
5306
5307
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5308 return qe_invalid;
5309 200 temp_misc.colors.overworld_map_tile = dummyw;
5310
5311
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5312 return qe_invalid;
5313 200 temp_misc.colors.dungeon_map_tile = dummyw;
5314
5315
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5316 return qe_invalid;
5317 200 temp_misc.colors.blueframe_tile = dummyw;
5318
5319
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5320 return qe_invalid;
5321 200 temp_misc.colors.HCpieces_tile = dummyw;
5322 200 }
5323
5324
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5325 {
5326 return qe_invalid;
5327 }
5328
5329
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5330 {
5331 return qe_invalid;
5332 }
5333
5334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(s_version < 2)
5335 {
5336 temp_misc.colors.msgtext = 0x01;
5337 }
5338 else
5339 {
5340
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_getc(&temp_misc.colors.msgtext, f))
5341 {
5342 return qe_invalid;
5343 }
5344 }
5345
5346
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if ( s_version >= 3 ) //expanded tile pages to 825
5347 {
5348
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5349 {
5350 return qe_invalid;
5351 }
5352
5353
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5354 {
5355 return qe_invalid;
5356 }
5357
5358
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5359 {
5360 return qe_invalid;
5361 }
5362
5363
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5364 {
5365 return qe_invalid;
5366 }
5367
5368
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5369 {
5370 return qe_invalid;
5371 }
5372
5373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5374 {
5375 return qe_invalid;
5376 }
5377 210 }
5378
5379 410 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5380
5381 410 return 0;
5382 410 }
5383
5384 410 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5385 {
5386 miscQdata temp_misc;
5387 410 word s_version=0;
5388 byte icons;
5389 410 int32_t tempsize=0;
5390
5391 410 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5392
5393 //section version info
5394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(!p_igetw(&s_version,f))
5395 {
5396 return qe_invalid;
5397 }
5398
5399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_ICONS)
5400 return qe_version;
5401
5402 410 FFCore.quest_format[vIcons] = s_version;
5403
5404
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
5405 {
5406 return qe_invalid;
5407 }
5408
5409
5410 //section size
5411
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&tempsize,f))
5412 {
5413 return qe_invalid;
5414 }
5415
5416 //finally... section data
5417 410 readsize=0;
5418
5419 410 icons=4;
5420
5421
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if ( s_version >= 10 )
5422 {
5423
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<icons; i++)
5424 {
5425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_igetl(&temp_misc.icons[i],f))
5426 {
5427 return qe_invalid;
5428 }
5429 840 }
5430 210 }
5431 else
5432 {
5433
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<icons; i++)
5434 {
5435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_igetw(&temp_misc.icons[i],f))
5436 {
5437 return qe_invalid;
5438 }
5439 800 }
5440 }
5441
5442 410 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5443
5444 410 return 0;
5445 410 }
5446
5447 824 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5448 {
5449
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 24 times.
824 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5450
5451 824 word maxinfos=256;
5452 824 word maxshops=256;
5453 824 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5454 824 word ponds=16, pondsize=72, expansionsize=98*2;
5455 byte tempbyte, padding;
5456 miscQdata temp_misc;
5457 824 word s_version=0;
5458 word swaptmp;
5459 824 int32_t tempsize=0;
5460
5461 824 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5462
5463
2/2
✓ Branch 0 taken 210944 times.
✓ Branch 1 taken 824 times.
211768 for(int32_t i=0; i<maxshops; ++i)
5464 {
5465 210944 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5466 210944 }
5467
5468
2/2
✓ Branch 0 taken 210944 times.
✓ Branch 1 taken 824 times.
211768 for(int32_t i=0; i<maxinfos; ++i)
5469 {
5470 210944 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5471 210944 }
5472
5473 824 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5474
5475
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(Header->zelda_version > 0x192)
5476 {
5477 //section version info
5478
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&s_version,f))
5479 {
5480 return qe_invalid;
5481 }
5482
5483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if (s_version > V_MISC)
5484 return qe_version;
5485
5486 800 FFCore.quest_format[vMisc] = s_version;
5487
5488
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!read_deprecated_section_cversion(f))
5489 {
5490 return qe_invalid;
5491 }
5492
5493
5494 //section size
5495
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetl(&tempsize,f))
5496 {
5497 return qe_invalid;
5498 }
5499 800 }
5500
5501 //finally... section data
5502 824 readsize=0;
5503
5504 //shops
5505
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(Header->zelda_version > 0x192)
5506 {
5507
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&shops,f))
5508 {
5509 return qe_invalid;
5510 }
5511 800 }
5512
5513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if (shops > NUM_SHOPS)
5514 {
5515 return qe_invalid;
5516 }
5517
5518
2/2
✓ Branch 0 taken 11262 times.
✓ Branch 1 taken 824 times.
12086 for(int32_t i=0; i<shops; i++)
5519 {
5520
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 10062 times.
11262 if(s_version > 6)
5521 {
5522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10062 times.
10062 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5523 {
5524 return qe_invalid;
5525 }
5526 10062 }
5527
5528
2/2
✓ Branch 0 taken 33786 times.
✓ Branch 1 taken 11262 times.
45048 for(int32_t j=0; j<3; j++)
5529 {
5530
1/2
✓ Branch 0 taken 33786 times.
✗ Branch 1 not taken.
33786 if(!p_getc(&temp_misc.shop[i].item[j],f))
5531 {
5532 return qe_invalid;
5533 }
5534
5535
2/2
✓ Branch 0 taken 30186 times.
✓ Branch 1 taken 3600 times.
33786 if(s_version < 4)
5536 {
5537 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5538 3600 }
5539 33786 }
5540
5541
2/2
✓ Branch 0 taken 10878 times.
✓ Branch 1 taken 384 times.
11262 if(Header->zelda_version < 0x193)
5542 {
5543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5544 {
5545 return qe_invalid;
5546 }
5547 384 }
5548
5549
2/2
✓ Branch 0 taken 33786 times.
✓ Branch 1 taken 11262 times.
45048 for(int32_t j=0; j<3; j++)
5550 {
5551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33786 times.
33786 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5552 {
5553 return qe_invalid;
5554 }
5555 33786 }
5556
5557
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 10062 times.
11262 if(s_version > 3)
5558 {
5559
2/2
✓ Branch 0 taken 30186 times.
✓ Branch 1 taken 10062 times.
40248 for(int32_t j=0; j<3; j++)
5560 {
5561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30186 times.
30186 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5562 return qe_invalid;
5563 30186 }
5564 10062 }
5565
5566 /*
5567 if(s_version < 8)
5568 {
5569 for(int32_t j=0; j<3; j++)
5570 {
5571 (&temp_misc.shop[i].str[j])=0; //initialise.
5572 }
5573 }
5574 */
5575 11262 }
5576
5577 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5578
2/2
✓ Branch 0 taken 210944 times.
✓ Branch 1 taken 824 times.
211768 for(int32_t i=0; i<maxshops; ++i)
5579 {
5580
2/2
✓ Branch 0 taken 421888 times.
✓ Branch 1 taken 210944 times.
632832 for(int32_t j=0; j<3-1; j++)
5581 {
5582
2/2
✓ Branch 0 taken 632832 times.
✓ Branch 1 taken 421888 times.
1054720 for(int32_t k=0; k<2-j; k++)
5583 {
5584
2/2
✓ Branch 0 taken 608531 times.
✓ Branch 1 taken 24301 times.
632832 if(temp_misc.shop[i].hasitem[k]==0)
5585 {
5586 608531 swaptmp = temp_misc.shop[i].item[k];
5587 608531 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5588 608531 temp_misc.shop[i].item[k+1] = swaptmp;
5589 608531 swaptmp = temp_misc.shop[i].price[k];
5590 608531 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5591 608531 temp_misc.shop[i].price[k+1] = swaptmp;
5592 608531 swaptmp = temp_misc.shop[i].hasitem[k];
5593 608531 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5594 608531 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5595 608531 }
5596 632832 }
5597 421888 }
5598 210944 }
5599
5600 //infos
5601
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(Header->zelda_version > 0x192)
5602 {
5603
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&infos,f))
5604 {
5605 return qe_invalid;
5606 }
5607 800 }
5608
5609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if (infos > NUM_INFOS)
5610 {
5611 return qe_invalid;
5612 }
5613
5614
5615
2/2
✓ Branch 0 taken 10568 times.
✓ Branch 1 taken 824 times.
11392 for(int32_t i=0; i<infos; i++)
5616 {
5617
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9807 times.
10568 if(s_version > 6)
5618 {
5619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9807 times.
9807 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5620 {
5621 return qe_invalid;
5622 }
5623 9807 }
5624
5625
2/2
✓ Branch 0 taken 31704 times.
✓ Branch 1 taken 10568 times.
42272 for(int32_t j=0; j<3; j++)
5626 {
5627
3/4
✓ Branch 0 taken 30840 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
31992 if((Header->zelda_version < 0x192)||
5628
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 30552 times.
30840 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5629 {
5630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5631 {
5632 return qe_invalid;
5633 }
5634
5635 864 temp_misc.info[i].str[j]=tempbyte;
5636 864 }
5637 else
5638 {
5639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30840 times.
30840 if(!p_igetw(&temp_misc.info[i].str[j],f))
5640 {
5641 return qe_invalid;
5642 }
5643 }
5644 31704 }
5645
5646
2/2
✓ Branch 0 taken 10184 times.
✓ Branch 1 taken 384 times.
10568 if(Header->zelda_version < 0x193)
5647 {
5648
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5649 {
5650 return qe_invalid;
5651 }
5652 384 }
5653
5654
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10568 if((Header->zelda_version == 0x192)&&(Header->build>145))
5655 {
5656
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5657 {
5658 return qe_invalid;
5659 }
5660 96 }
5661
5662
2/2
✓ Branch 0 taken 31704 times.
✓ Branch 1 taken 10568 times.
42272 for(int32_t j=0; j<3; j++)
5663 {
5664
1/2
✓ Branch 0 taken 31704 times.
✗ Branch 1 not taken.
31704 if(!p_igetw(&temp_misc.info[i].price[j],f))
5665 {
5666 return qe_invalid;
5667 }
5668 31704 }
5669 10568 }
5670
5671 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5672
2/2
✓ Branch 0 taken 210944 times.
✓ Branch 1 taken 824 times.
211768 for(int32_t i=0; i<maxinfos; ++i)
5673 {
5674
2/2
✓ Branch 0 taken 421888 times.
✓ Branch 1 taken 210944 times.
632832 for(int32_t j=0; j<3-1; j++)
5675 {
5676
2/2
✓ Branch 0 taken 632832 times.
✓ Branch 1 taken 421888 times.
1054720 for(int32_t k=0; k<2-j; k++)
5677 {
5678
2/2
✓ Branch 0 taken 11968 times.
✓ Branch 1 taken 620864 times.
632832 if(temp_misc.info[i].str[k]==0)
5679 {
5680 620864 swaptmp = temp_misc.info[i].str[k];
5681 620864 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5682 620864 temp_misc.info[i].str[k+1] = swaptmp;
5683 620864 swaptmp = temp_misc.info[i].price[k];
5684 620864 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5685 620864 temp_misc.info[i].price[k+1] = swaptmp;
5686 620864 }
5687 632832 }
5688 421888 }
5689 210944 }
5690
5691
5692 //warp rings
5693
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 741 times.
824 if(s_version > 5)
5694 741 warprings++;
5695
5696
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(Header->zelda_version > 0x192)
5697 {
5698
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&warprings,f))
5699 {
5700 return qe_invalid;
5701 }
5702
5703
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 458 times.
800 if (warprings > NUM_WARP_RINGS)
5704 {
5705 // return qe_invalid;
5706 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5707 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5708 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5709 458 }
5710 800 }
5711
5712
2/2
✓ Branch 0 taken 8660 times.
✓ Branch 1 taken 824 times.
9484 for(int32_t i=0; i<warprings; i++)
5713 {
5714 // See above comment on the `warprings` range check.
5715 8660 bool keepdata = i < NUM_WARP_RINGS;
5716
5717
2/2
✓ Branch 0 taken 76820 times.
✓ Branch 1 taken 8660 times.
85480 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5718 {
5719
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 67860 times.
76820 if(s_version <= 3)
5720 {
5721
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5722 {
5723 return qe_invalid;
5724 }
5725
5726
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5727 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5728 8960 }
5729 else
5730 {
5731 word tempword;
5732
1/2
✓ Branch 0 taken 67860 times.
✗ Branch 1 not taken.
67860 if(!p_igetw(&tempword,f))
5733 {
5734 return qe_invalid;
5735 }
5736
5737
2/2
✓ Branch 0 taken 8145 times.
✓ Branch 1 taken 59715 times.
67860 if (keepdata)
5738 59715 temp_misc.warp[i].dmap[j] = tempword;
5739 }
5740 76820 }
5741
5742
2/2
✓ Branch 0 taken 76820 times.
✓ Branch 1 taken 8660 times.
85480 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5743 {
5744
1/2
✓ Branch 0 taken 76820 times.
✗ Branch 1 not taken.
76820 if(!p_getc(&tempbyte,f))
5745 {
5746 return qe_invalid;
5747 }
5748
2/2
✓ Branch 0 taken 11337 times.
✓ Branch 1 taken 65483 times.
76820 if (keepdata)
5749 65483 temp_misc.warp[i].scr[j] = tempbyte;
5750 76820 }
5751
5752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8660 times.
8660 if(!p_getc(&tempbyte,f))
5753 {
5754 return qe_invalid;
5755 }
5756
2/2
✓ Branch 0 taken 1304 times.
✓ Branch 1 taken 7356 times.
8660 if (keepdata)
5757 7356 temp_misc.warp[i].size = tempbyte;
5758
5759
2/2
✓ Branch 0 taken 8468 times.
✓ Branch 1 taken 192 times.
8660 if(Header->zelda_version < 0x193)
5760 {
5761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5762 {
5763 return qe_invalid;
5764 }
5765 192 }
5766 8660 }
5767
5768 //palette cycles
5769
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 24 times.
824 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5770 {
5771
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5772 {
5773
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5774 {
5775 18432 temp_misc.cycles[i][j].first=0;
5776 18432 temp_misc.cycles[i][j].count=0;
5777 18432 temp_misc.cycles[i][j].speed=0;
5778 18432 }
5779 6144 }
5780
5781
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5782
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5783 {
5784 18 palcycles=16;
5785 18 }
5786
5787
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5788 {
5789
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5790 {
5791
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5792 {
5793 return qe_invalid;
5794 }
5795
5796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5797 {
5798 return qe_invalid;
5799 }
5800
5801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5802 {
5803 return qe_invalid;
5804 }
5805 5472 }
5806 1824 }
5807 24 }
5808
5809 //Wind warps are now just another warp ring.
5810
2/2
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 83 times.
824 if(s_version <= 5)
5811 {
5812
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5813 {
5814
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5815 {
5816 return qe_invalid;
5817 }
5818 59 }
5819
5820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5821 {
5822 return qe_invalid;
5823 }
5824
5825
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5826 {
5827
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5828 {
5829
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5830 {
5831 return qe_invalid;
5832 }
5833
5834 665 temp_misc.warp[8].dmap[i]=tempbyte;
5835 665 }
5836 else
5837 {
5838 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5839 {
5840 return qe_invalid;
5841 }
5842 }
5843
5844
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5845 {
5846 return qe_invalid;
5847 }
5848
5849 665 temp_misc.warp[8].size = 9;
5850
5851
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5852 {
5853 if(!p_getc(&tempbyte,f))
5854 {
5855 return qe_invalid;
5856 }
5857 }
5858 665 }
5859 83 }
5860
5861
5862 //triforce pieces
5863
2/2
✓ Branch 0 taken 6592 times.
✓ Branch 1 taken 824 times.
7416 for(int32_t i=0; i<triforces; i++)
5864 {
5865
1/2
✓ Branch 0 taken 6592 times.
✗ Branch 1 not taken.
6592 if(!p_getc(&temp_misc.triforce[i],f))
5866 {
5867 return qe_invalid;
5868 }
5869 6592 }
5870
5871 //misc color data
5872
2/2
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 83 times.
824 if(s_version<3)
5873 {
5874
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5875 {
5876 return qe_invalid;
5877 }
5878
5879
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5880 {
5881 return qe_invalid;
5882 }
5883
5884
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5885 {
5886 return qe_invalid;
5887 }
5888
5889
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5890 {
5891 return qe_invalid;
5892 }
5893
5894
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5895 {
5896 return qe_invalid;
5897 }
5898
5899
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5900 {
5901 return qe_invalid;
5902 }
5903
5904
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5905 {
5906 return qe_invalid;
5907 }
5908
5909
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5910 {
5911 return qe_invalid;
5912 }
5913
5914
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5915 {
5916 return qe_invalid;
5917 }
5918
5919
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5925 {
5926 return qe_invalid;
5927 }
5928
5929
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5930 {
5931 return qe_invalid;
5932 }
5933
5934
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5935 {
5936 return qe_invalid;
5937 }
5938
5939
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5980 {
5981 return qe_invalid;
5982 }
5983
5984
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5985 {
5986 return qe_invalid;
5987 }
5988
5989
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5990 {
5991 return qe_invalid;
5992 }
5993
5994
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5995 {
5996 return qe_invalid;
5997 }
5998
5999
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6000 {
6001 return qe_invalid;
6002 }
6003
6004
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6005 {
6006 return qe_invalid;
6007 }
6008
6009 83 temp_misc.colors.msgtext = 0x01;
6010
6011
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
6012 {
6013
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6014 {
6015
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
6016 {
6017 return qe_invalid;
6018 }
6019 168 }
6020 24 }
6021
6022
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6023 {
6024
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6025 {
6026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6027 {
6028 return qe_invalid;
6029 }
6030 1536 }
6031 6 }
6032
6033
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6034 {
6035 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6036 {
6037 return qe_invalid;
6038 }
6039 }
6040
6041 //save game icons
6042
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6043
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6044 {
6045 18 icons=3;
6046 18 }
6047
6048
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6049 {
6050
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6051 {
6052 return qe_invalid;
6053 }
6054 314 }
6055 83 }
6056
6057
3/4
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
830 if((Header->zelda_version < 0x192)||
6058
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 800 times.
806 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6059 {
6060 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6061
6062 18 return 0;
6063 }
6064
6065 //pond information
6066
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 6 times.
806 if(Header->zelda_version < 0x193)
6067 {
6068
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6069 {
6070 pondsize=25;
6071 }
6072
6073
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6074 {
6075
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6076 {
6077
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6078 {
6079 return qe_invalid;
6080
6081 }
6082 6912 }
6083 96 }
6084 6 }
6085
6086 //end string
6087
2/4
✓ Branch 0 taken 806 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
812 if((Header->zelda_version < 0x192)||
6088
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 800 times.
806 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6089 {
6090 if(!p_getc(&tempbyte,f))
6091 {
6092 return qe_invalid;
6093 }
6094
6095 temp_misc.endstring=tempbyte;
6096
6097 if(!p_getc(&tempbyte,f))
6098 {
6099 return qe_invalid;
6100 }
6101 }
6102 else
6103 {
6104
1/2
✓ Branch 0 taken 806 times.
✗ Branch 1 not taken.
806 if(!p_igetw(&temp_misc.endstring,f))
6105 {
6106 return qe_invalid;
6107 }
6108 }
6109
6110 //expansion
6111
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 6 times.
806 if(Header->zelda_version < 0x193)
6112 {
6113
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6114 {
6115 expansionsize=99*2;
6116 }
6117
6118
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6119 {
6120
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6121 {
6122 return qe_invalid;
6123 }
6124 1176 }
6125 6 }
6126 //shops v8
6127
6128
6129
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 210 times.
806 if(s_version >= 8)
6130 {
6131
2/2
✓ Branch 0 taken 2448 times.
✓ Branch 1 taken 210 times.
2658 for(int32_t i=0; i<shops; i++)
6132 {
6133
2/2
✓ Branch 0 taken 7344 times.
✓ Branch 1 taken 2448 times.
9792 for(int32_t j=0; j<3; j++)
6134 {
6135
1/2
✓ Branch 0 taken 7344 times.
✗ Branch 1 not taken.
7344 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6136 return qe_invalid;
6137 7344 }
6138 2448 }
6139 210 }
6140
6141 806 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6142 806 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6143
6144 //v9 includes quest misc[32]
6145 // ... this has been deprecated (2024)
6146
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 210 times.
806 if(s_version >= 9)
6147 {
6148
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 210 times.
6930 for ( int32_t q = 0; q < 32; q++ )
6149 {
6150
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if(!p_igetl(&temp_misc.questmisc[q],f))
6151 return qe_invalid;
6152 6720 }
6153 // this was string labels
6154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if (pack_fseek(f, 32 * 128))
6155 return qe_invalid;
6156 210 }
6157
6158
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 596 times.
806 if(s_version >= 11 )
6159 {
6160
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6161 return qe_invalid;
6162 210 }
6163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 596 times.
596 else if(s_version < 11 )
6164 {
6165 596 temp_misc.zscript_last_compiled_version = -1;
6166 596 }
6167
6168 806 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6169
6170
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 596 times.
806 if(s_version >= 12)
6171 {
6172 byte spr;
6173
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t q = 0; q < sprMAX; ++q)
6174 {
6175
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&spr,f))
6176 return qe_invalid;
6177 53760 temp_misc.sprites[q] = spr;
6178 53760 }
6179 210 }
6180 else
6181 {
6182 596 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6183 //temp_misc.sprites[sprFALL] = ;
6184 }
6185
6186
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 596 times.
806 if(s_version >= 13)
6187 {
6188
2/2
✓ Branch 0 taken 13440 times.
✓ Branch 1 taken 210 times.
13650 for(size_t q = 0; q < 64; ++q)
6189 {
6190 13440 bottletype* bt = &(temp_misc.bottle_types[q]);
6191
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6192 return qe_invalid;
6193
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 13440 times.
53760 for(size_t j = 0; j < 3; ++j)
6194 {
6195
1/2
✓ Branch 0 taken 40320 times.
✗ Branch 1 not taken.
40320 if (!p_getc(&(bt->counter[j]), f))
6196 return qe_invalid;
6197
1/2
✓ Branch 0 taken 40320 times.
✗ Branch 1 not taken.
40320 if (!p_igetw(&(bt->amount[j]), f))
6198 return qe_invalid;
6199 40320 }
6200
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if (!p_getc(&(bt->flags), f))
6201 return qe_invalid;
6202
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if (!p_getc(&(bt->next_type), f))
6203 return qe_invalid;
6204 13440 }
6205
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(size_t q = 0; q < 256; ++q)
6206 {
6207 53760 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6208
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6209 return qe_invalid;
6210
2/2
✓ Branch 0 taken 161280 times.
✓ Branch 1 taken 53760 times.
215040 for(size_t j = 0; j < 3; ++j)
6211 {
6212
1/2
✓ Branch 0 taken 161280 times.
✗ Branch 1 not taken.
161280 if (!p_getc(&(bst->fill[j]), f))
6213 return qe_invalid;
6214
1/2
✓ Branch 0 taken 161280 times.
✗ Branch 1 not taken.
161280 if (!p_igetw(&(bst->comb[j]), f))
6215 return qe_invalid;
6216
1/2
✓ Branch 0 taken 161280 times.
✗ Branch 1 not taken.
161280 if (!p_getc(&(bst->cset[j]), f))
6217 return qe_invalid;
6218
1/2
✓ Branch 0 taken 161280 times.
✗ Branch 1 not taken.
161280 if (!p_igetw(&(bst->price[j]), f))
6219 return qe_invalid;
6220
1/2
✓ Branch 0 taken 161280 times.
✗ Branch 1 not taken.
161280 if (!p_igetw(&(bst->str[j]), f))
6221 return qe_invalid;
6222 161280 }
6223 53760 }
6224 210 }
6225 else
6226 {
6227
2/2
✓ Branch 0 taken 38144 times.
✓ Branch 1 taken 596 times.
38740 for(size_t q = 0; q < 64; ++q)
6228 38144 temp_misc.bottle_types[q].clear();
6229
2/2
✓ Branch 0 taken 152576 times.
✓ Branch 1 taken 596 times.
153172 for(size_t q = 0; q < 256; ++q)
6230 152576 temp_misc.bottle_shop_types[q].clear();
6231 }
6232
6233
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 596 times.
806 if(s_version >= 14)
6234 {
6235 byte msfx;
6236
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t q = 0; q < sfxMAX; ++q)
6237 {
6238
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&msfx,f))
6239 return qe_invalid;
6240 53760 temp_misc.miscsfx[q] = msfx;
6241 53760 }
6242 210 }
6243 else
6244 {
6245 596 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6246 596 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6247 596 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6248 }
6249
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 596 times.
806 if(s_version < 15)
6250 {
6251 596 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6252 596 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6253 596 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6254 596 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6255 596 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6256 596 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6257 596 }
6258
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 613 times.
806 if(s_version < 16)
6259 {
6260 613 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6261 613 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6262 613 }
6263
6264
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 805 times.
806 if (!should_skip)
6265 805 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6266
6267 806 return 0;
6268 824 }
6269
6270 extern char *item_string[MAXITEMS];
6271 extern const char *old_item_string[iLast];
6272 extern char *weapon_string[MAXWPNS];
6273 extern const char *old_weapon_string[wLast];
6274
6275 493 int32_t readitems(PACKFILE *f, word version, word build)
6276 {
6277
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6278
6279 byte padding;
6280 int32_t dummy;
6281 493 word items_to_read=MAXITEMS;
6282 493 itemdata tempitem;
6283 493 word s_version=0;
6284 word dummy_word;
6285
6286
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 6 times.
493 if(version < 0x186)
6287 {
6288 6 items_to_read=64;
6289 6 }
6290
6291
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 469 times.
493 if(version > 0x192)
6292 {
6293 469 items_to_read=0;
6294
6295 //section version info
6296
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&s_version,f))
6297 {
6298 return qe_invalid;
6299 }
6300
6301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (s_version > V_ITEMS)
6302 return qe_version;
6303
6304 469 FFCore.quest_format[vItems] = s_version;
6305
6306
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!read_deprecated_section_cversion(f))
6307 {
6308 return qe_invalid;
6309 }
6310
6311 //section size
6312
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy,f))
6313 {
6314 return qe_invalid;
6315 }
6316
6317 //finally... section data
6318
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&items_to_read,f))
6319 {
6320 return qe_invalid;
6321 }
6322
6323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (items_to_read > MAXITEMS)
6324 {
6325 return qe_invalid;
6326 }
6327 469 }
6328
6329
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 83 times.
493 if(s_version>1)
6330 {
6331
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i=0; i<items_to_read; i++)
6332 {
6333 char tempname[64];
6334
6335
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!pfread(tempname, 64, f))
6336 {
6337 return qe_invalid;
6338 }
6339
6340 104960 item_string[i][0] = '\0';
6341 104960 strncat(item_string[i], tempname, 64 - 1);
6342 104960 }
6343 410 }
6344
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6345 {
6346
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6347 {
6348 20992 reset_itemname(i);
6349 20992 }
6350 82 }
6351
6352
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 492 times.
493 if (!should_skip)
6353
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<MAXITEMS; i++)
6354 {
6355 125952 itemdata& id = itemsbuf[i];
6356 125952 memset(&id, 0, sizeof(itemdata));
6357 125952 id.count=-1;
6358 125952 id.playsound=WAV_SCALE;
6359 125952 reset_itembuf(&id,i);
6360 126444 }
6361
6362
2/2
✓ Branch 0 taken 114082 times.
✓ Branch 1 taken 493 times.
114575 for(int32_t i=0; i<items_to_read; i++)
6363 {
6364 114082 tempitem = itemdata();
6365 114082 reset_itembuf(&tempitem,i);
6366
6367
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 60322 times.
114082 if ( s_version > 35 ) //expanded tiles
6368 {
6369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.tile,f))
6370 {
6371 return qe_invalid;
6372 }
6373 53760 }
6374 else
6375 {
6376
1/2
✓ Branch 0 taken 60322 times.
✗ Branch 1 not taken.
60322 if(!p_igetw(&tempitem.tile,f))
6377 {
6378 return qe_invalid;
6379 }
6380 }
6381
6382
1/2
✓ Branch 0 taken 114082 times.
✗ Branch 1 not taken.
114082 if(!p_getc(&tempitem.misc_flags,f))
6383 {
6384 return qe_invalid;
6385 }
6386
6387
1/2
✓ Branch 0 taken 114082 times.
✗ Branch 1 not taken.
114082 if(!p_getc(&tempitem.csets,f))
6388 {
6389 return qe_invalid;
6390 }
6391
6392
1/2
✓ Branch 0 taken 114082 times.
✗ Branch 1 not taken.
114082 if(!p_getc(&tempitem.frames,f))
6393 {
6394 return qe_invalid;
6395 }
6396
6397
1/2
✓ Branch 0 taken 114082 times.
✗ Branch 1 not taken.
114082 if(!p_getc(&tempitem.speed,f))
6398 {
6399 return qe_invalid;
6400 }
6401
6402
1/2
✓ Branch 0 taken 114082 times.
✗ Branch 1 not taken.
114082 if(!p_getc(&tempitem.delay,f))
6403 {
6404 return qe_invalid;
6405 }
6406
6407
2/2
✓ Branch 0 taken 109090 times.
✓ Branch 1 taken 4992 times.
114082 if(version < 0x193)
6408 {
6409
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6410 {
6411 return qe_invalid;
6412 }
6413
6414
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6415 {
6416
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6417 256 continue;
6418
6419
3/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4690 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6420 {
6421 case iShield:
6422 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6423 23 break;
6424
6425 case iMShield:
6426 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6427 23 break;
6428
6429 default:
6430 4690 tempitem.ltm=0;
6431 4690 break;
6432 }
6433
6434 4736 tempitem.count=-1;
6435 4736 tempitem.flags=item_none;
6436 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6437 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6438 4736 tempitem.type=0xFF;
6439 4736 tempitem.playsound=WAV_SCALE;
6440 4736 reset_itembuf(&tempitem,i);
6441
6442 4736 itemsbuf[i] = tempitem;
6443
6444 4736 continue;
6445 }
6446 }
6447
6448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109090 times.
109090 if(!p_igetl(&tempitem.ltm,f))
6449 {
6450 return qe_invalid;
6451 }
6452
6453
1/2
✓ Branch 0 taken 109090 times.
✗ Branch 1 not taken.
109090 if(version < 0x193)
6454 {
6455 for(int32_t q=0; q<12; q++)
6456 {
6457 if(!p_getc(&padding,f))
6458 {
6459 return qe_invalid;
6460 }
6461 }
6462 }
6463
6464
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 4130 times.
109090 if(s_version>1)
6465 {
6466
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 51200 times.
104960 if ( s_version >= 31 )
6467 {
6468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.type,f))
6469 {
6470 return qe_invalid;
6471 }
6472 53760 }
6473 else
6474 {
6475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.type,f))
6476 {
6477 return qe_invalid;
6478 }
6479 }
6480
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(s_version < 16)
6481 if(tempitem.type == 0xFF)
6482 tempitem.type = itype_misc;
6483
6484
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.level,f))
6485 {
6486 return qe_invalid;
6487 }
6488
6489
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(s_version>5)
6490 {
6491
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 51200 times.
104960 if(s_version>=31)
6492 {
6493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.power,f))
6494 {
6495 return qe_invalid;
6496 }
6497 53760 }
6498 else
6499 {
6500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.power,f))
6501 {
6502 return qe_invalid;
6503 }
6504 }
6505
6506 //converted flags from 16b to 32b -Z
6507
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version < 41 )
6508 {
6509
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempitem.flags,f))
6510 {
6511 return qe_invalid;
6512 }
6513 51200 }
6514 else
6515 {
6516
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.flags,f))
6517 {
6518 return qe_invalid;
6519 }
6520 }
6521 104960 }
6522 else
6523 {
6524 //tempitem.power = tempitem.fam_type;
6525 char tempchar;
6526
6527 if(!p_getc(&tempchar,f))
6528 {
6529 return qe_invalid;
6530 }
6531
6532 if (tempchar) tempitem.flags |= item_gamedata;
6533 }
6534
6535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetw(&tempitem.script,f))
6536 {
6537 return qe_invalid;
6538 }
6539
6540
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(s_version<=3)
6541 {
6542 if(tempitem.script > NUMSCRIPTITEM)
6543 {
6544 tempitem.script = 0;
6545 }
6546 }
6547
6548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.count,f))
6549 {
6550 return qe_invalid;
6551 }
6552
6553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetw(&tempitem.amount,f))
6554 {
6555 return qe_invalid;
6556 }
6557
6558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetw(&tempitem.collect_script,f))
6559 {
6560 return qe_invalid;
6561 }
6562
6563
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(s_version<=3)
6564 {
6565 if(tempitem.collect_script > NUMSCRIPTITEM)
6566 {
6567 tempitem.collect_script = 0;
6568 }
6569 }
6570
6571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetw(&tempitem.setmax,f))
6572 {
6573 return qe_invalid;
6574 }
6575
6576
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&tempitem.max,f))
6577 {
6578 return qe_invalid;
6579 }
6580
6581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.playsound,f))
6582 {
6583 return qe_invalid;
6584 }
6585
6586
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for(int32_t j=0; j<8; j++)
6587 {
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 839680 times.
839680 if(!p_igetl(&tempitem.initiald[j],f))
6589 {
6590 return qe_invalid;
6591 }
6592 839680 }
6593
6594
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 104960 times.
314880 for(int32_t j=0; j<2; j++)
6595 {
6596 byte temp;
6597
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&temp,f))
6598 {
6599 return qe_invalid;
6600 }
6601 209920 }
6602
6603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(s_version>4)
6604 {
6605
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(s_version>5)
6606 {
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.wpn,f))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.wpn2,f))
6613 {
6614 return qe_invalid;
6615 }
6616
6617
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.wpn3,f))
6618 {
6619 return qe_invalid;
6620 }
6621
6622
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.wpn4,f))
6623 {
6624 return qe_invalid;
6625 }
6626
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(s_version>=15)
6628 {
6629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.wpn5,f))
6630 {
6631 return qe_invalid;
6632 }
6633
6634
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.wpn6,f))
6635 {
6636 return qe_invalid;
6637 }
6638
6639
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.wpn7,f))
6640 {
6641 return qe_invalid;
6642 }
6643
6644
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.wpn8,f))
6645 {
6646 return qe_invalid;
6647 }
6648
6649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.wpn9,f))
6650 {
6651 return qe_invalid;
6652 }
6653
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_getc(&tempitem.wpn10,f))
6655 {
6656 return qe_invalid;
6657 }
6658 104960 }
6659
6660
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.pickup_hearts,f))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(s_version<15)
6666 {
6667 if(!p_igetw(&dummy_word,f))
6668 {
6669 return qe_invalid;
6670 }
6671
6672 tempitem.misc1=dummy_word;
6673
6674 if(!p_igetw(&dummy_word,f))
6675 {
6676 return qe_invalid;
6677 }
6678
6679 tempitem.misc2=dummy_word;
6680 }
6681 else
6682 {
6683
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&tempitem.misc1,f))
6684 {
6685 return qe_invalid;
6686 }
6687
6688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetl(&tempitem.misc2,f))
6689 {
6690 return qe_invalid;
6691 }
6692
6693 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6694
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(s_version<24)
6695 {
6696 if(tempitem.type==itype_shield)
6697 {
6698 tempitem.misc1|=sh_script;
6699 }
6700 }
6701 }
6702
6703
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if(s_version < 53)
6704 {
6705 byte tempbyte;
6706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempbyte,f))
6707 {
6708 return qe_invalid;
6709 }
6710 51200 tempitem.cost_amount[0] = tempbyte;
6711 51200 }
6712 else
6713 {
6714
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 53760 times.
161280 for(auto q = 0; q < 2; ++q)
6715 {
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107520 times.
107520 if(!p_igetw(&tempitem.cost_amount[q],f))
6717 {
6718 return qe_invalid;
6719 }
6720 107520 }
6721 }
6722 104960 }
6723 else
6724 {
6725 char tempchar;
6726
6727 if(!p_getc(&tempchar,f))
6728 {
6729 return qe_invalid;
6730 }
6731
6732 if (tempchar) tempitem.flags |= item_edible;
6733 }
6734
6735 // June 2007: more misc. attributes
6736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(s_version>=12)
6737 {
6738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(s_version<15)
6739 {
6740 if(!p_igetw(&dummy_word,f))
6741 {
6742 return qe_invalid;
6743 }
6744
6745 tempitem.misc3=dummy_word;
6746
6747 if(!p_igetw(&dummy_word,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752 tempitem.misc4=dummy_word;
6753 }
6754 else
6755 {
6756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetl(&tempitem.misc3,f))
6757 {
6758 return qe_invalid;
6759 }
6760
6761
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&tempitem.misc4,f))
6762 {
6763 return qe_invalid;
6764 }
6765
6766
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&tempitem.misc5,f))
6767 {
6768 return qe_invalid;
6769 }
6770
6771
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&tempitem.misc6,f))
6772 {
6773 return qe_invalid;
6774 }
6775
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetl(&tempitem.misc7,f))
6777 {
6778 return qe_invalid;
6779 }
6780
6781
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&tempitem.misc8,f))
6782 {
6783 return qe_invalid;
6784 }
6785
6786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if(!p_igetl(&tempitem.misc9,f))
6787 {
6788 return qe_invalid;
6789 }
6790
6791
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&tempitem.misc10,f))
6792 {
6793 return qe_invalid;
6794 }
6795 }
6796
6797
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_getc(&tempitem.usesound,f))
6798 {
6799 return qe_invalid;
6800 }
6801
6802
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 51200 times.
104960 if(s_version >= 49)
6803 {
6804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_getc(&tempitem.usesound2,f))
6805 {
6806 return qe_invalid;
6807 }
6808 53760 }
6809 51200 else tempitem.usesound2 = 0;
6810
6811
3/4
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
104960 if(s_version < 50 && tempitem.type == itype_mirror)
6812 {
6813 //Split continue/dmap warp effect/sfx, port for old
6814 tempitem.misc2 = tempitem.misc1;
6815 tempitem.usesound2 = tempitem.usesound;
6816 }
6817 104960 }
6818 104960 }
6819
6820
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6821 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6822
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 13056 times.
53760 if(s_version < 63)
6823 {
6824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13056 times.
13056 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6825 {
6826 return qe_invalid;
6827 }
6828
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_getc(&tempitem.weap_data.default_defense,f))
6829 {
6830 return qe_invalid;
6831 }
6832 13056 }
6833
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.weaprange,f))
6834 {
6835 return qe_invalid;
6836 }
6837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.weapduration,f))
6838 {
6839 return qe_invalid;
6840 }
6841
2/2
✓ Branch 0 taken 537600 times.
✓ Branch 1 taken 53760 times.
591360 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6842 {
6843
1/2
✓ Branch 0 taken 537600 times.
✗ Branch 1 not taken.
537600 if(!p_igetl(&tempitem.weap_pattern[q],f))
6844 {
6845 return qe_invalid;
6846 }
6847 537600 }
6848 53760 }
6849
6850
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6851 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.duplicates,f))
6853 {
6854 return qe_invalid;
6855 }
6856
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 13056 times.
53760 if(s_version < 63)
6857
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 13056 times.
117504 for ( int32_t q = 0; q < INITIAL_D; q++ )
6858
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6859 13056 return qe_invalid;
6860
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 53760 times.
161280 for ( int32_t q = 0; q < 2; q++ )
6861 {
6862 byte temp;
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107520 times.
107520 if(!p_getc(&temp,f))
6864 {
6865 return qe_invalid;
6866 }
6867 107520 }
6868
6869
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempitem.drawlayer,f))
6870 {
6871 return qe_invalid;
6872 }
6873
6874
6875
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.hxofs,f))
6876 {
6877 return qe_invalid;
6878 }
6879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.hyofs,f))
6880 {
6881 return qe_invalid;
6882 }
6883
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.hxsz,f))
6884 {
6885 return qe_invalid;
6886 }
6887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.hysz,f))
6888 {
6889 return qe_invalid;
6890 }
6891
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.hzsz,f))
6892 {
6893 return qe_invalid;
6894 }
6895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.xofs,f))
6896 {
6897 return qe_invalid;
6898 }
6899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.yofs,f))
6900 {
6901 return qe_invalid;
6902 }
6903
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 13056 times.
53760 if(s_version < 63)
6904 {
6905
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hxofs,f))
6906 return qe_invalid;
6907
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hyofs,f))
6908 return qe_invalid;
6909
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hxsz,f))
6910 return qe_invalid;
6911
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hysz,f))
6912 return qe_invalid;
6913
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hzsz,f))
6914 return qe_invalid;
6915
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.xofs,f))
6916 return qe_invalid;
6917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13056 times.
13056 if(!p_igetl(&tempitem.weap_data.yofs,f))
6918 return qe_invalid;
6919 13056 }
6920
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 13056 times.
53760 if(s_version < 63)
6921
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetw(&tempitem.weap_data.script,f))
6922 return qe_invalid;
6923
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.wpnsprite,f))
6924 {
6925 return qe_invalid;
6926 }
6927 53760 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6928
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 53760 times.
161280 for(auto q = 0; q < num_cost_tmr; ++q)
6929 {
6930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107520 times.
107520 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6931 {
6932 return qe_invalid;
6933 }
6934 107520 }
6935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 for(auto q = num_cost_tmr; q < 2; ++q)
6936 tempitem.magiccosttimer[q] = 0;
6937 53760 }
6938
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6939 {
6940 //Item Size FLags, TileWidth, TileHeight
6941
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.overrideFLAGS,f))
6942 {
6943 return qe_invalid;
6944 }
6945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.tilew,f))
6946 {
6947 return qe_invalid;
6948 }
6949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_igetl(&tempitem.tileh,f))
6950 {
6951 return qe_invalid;
6952 }
6953 53760 }
6954
4/4
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 51200 times.
✓ Branch 2 taken 40704 times.
✓ Branch 3 taken 13056 times.
104960 if ( s_version >= 29 && s_version < 63) //! More new vars.
6955 {
6956
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.override_flags,f))
6957 return qe_invalid;
6958
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.tilew,f))
6959 return qe_invalid;
6960
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.tileh,f))
6961 return qe_invalid;
6962 13056 }
6963
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 30 ) //! More new vars.
6964 {
6965 //Pickup Type
6966
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempitem.pickup,f))
6967 {
6968 return qe_invalid;
6969 }
6970 53760 }
6971
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 32 ) //! More new vars.
6972 {
6973 //Pickup Type
6974
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempitem.pstring,f))
6975 {
6976 return qe_invalid;
6977 }
6978 53760 }
6979
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 33 ) //! More new vars.
6980 {
6981 //Pickup Type
6982
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempitem.pickup_string_flags,f))
6983 {
6984 return qe_invalid;
6985 }
6986 53760 }
6987
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 34 ) //! cost counter
6988 {
6989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(s_version < 53)
6990 {
6991 if(!p_getc(&tempitem.cost_counter[0],f))
6992 {
6993 return qe_invalid;
6994 }
6995 }
6996 else
6997 {
6998
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 53760 times.
161280 for(auto q = 0; q < 2; ++q)
6999 {
7000
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_getc(&tempitem.cost_counter[q],f))
7001 {
7002 return qe_invalid;
7003 }
7004 107520 }
7005 }
7006 53760 }
7007
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 44 ) //! sprite scripts
7008 {
7009
2/2
✓ Branch 0 taken 430080 times.
✓ Branch 1 taken 53760 times.
483840 for ( int32_t q = 0; q < 8; q++ )
7010 {
7011
2/2
✓ Branch 0 taken 27955200 times.
✓ Branch 1 taken 430080 times.
28385280 for ( int32_t w = 0; w < 65; w++ )
7012 {
7013
1/2
✓ Branch 0 taken 27955200 times.
✗ Branch 1 not taken.
27955200 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7014 {
7015 return qe_invalid;
7016 }
7017 27955200 }
7018
2/2
✓ Branch 0 taken 325632 times.
✓ Branch 1 taken 104448 times.
430080 if(s_version < 63)
7019
2/2
✓ Branch 0 taken 6789120 times.
✓ Branch 1 taken 104448 times.
6893568 for ( int32_t w = 0; w < 65; w++ )
7020
1/2
✓ Branch 0 taken 6789120 times.
✗ Branch 1 not taken.
6789120 if(!p_getc(&padding,f))
7021 104448 return qe_invalid;
7022
2/2
✓ Branch 0 taken 27955200 times.
✓ Branch 1 taken 430080 times.
28385280 for ( int32_t w = 0; w < 65; w++ )
7023 {
7024
1/2
✓ Branch 0 taken 27955200 times.
✗ Branch 1 not taken.
27955200 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7025 {
7026 return qe_invalid;
7027 }
7028 27955200 }
7029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430080 times.
430080 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7030 {
7031 return qe_invalid;
7032 }
7033
7034 430080 }
7035
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 53760 times.
161280 for ( int32_t q = 0; q < 2; q++ )
7036 {
7037 byte temp;
7038
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_getc(&temp,f))
7039 {
7040 return qe_invalid;
7041 }
7042 107520 }
7043 //Pickup Type
7044
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempitem.sprite_script,f))
7045 {
7046 return qe_invalid;
7047 }
7048 53760 }
7049
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53760 times.
104960 if ( s_version >= 48 ) //! pickup flags
7050 {
7051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(!p_getc(&(tempitem.pickupflag),f))
7052 {
7053 return qe_invalid;
7054 }
7055 53760 }
7056
2/2
✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 50432 times.
104960 if ( s_version >= 57 )
7057 {
7058 50432 std::string str;
7059
2/4
✓ Branch 0 taken 50432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50432 times.
✗ Branch 3 not taken.
50432 if(!p_getcstr(&str,f))
7060 return qe_invalid;
7061 50432 strncpy(tempitem.display_name,str.c_str(),255);
7062
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 50432 times.
50432 }
7063 104960 }
7064 else
7065 {
7066 4130 tempitem.count=-1;
7067 4130 tempitem.type=itype_misc;
7068 4130 tempitem.flags=item_none;
7069 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7070 4130 tempitem.playsound=WAV_SCALE;
7071 4130 reset_itembuf(&tempitem,i);
7072 }
7073
7074
4/4
✓ Branch 0 taken 49408 times.
✓ Branch 1 taken 59682 times.
✓ Branch 2 taken 40704 times.
✓ Branch 3 taken 8704 times.
109090 if(s_version >= 58 && s_version < 63)
7075 {
7076
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 8704 times.
52224 for(int q = 0; q < WPNSPR_MAX; ++q)
7077 {
7078
1/2
✓ Branch 0 taken 43520 times.
✗ Branch 1 not taken.
43520 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7079 return qe_invalid;
7080
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 42240 times.
43520 if(s_version >= 59)
7081
1/2
✓ Branch 0 taken 42240 times.
✗ Branch 1 not taken.
42240 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7082 return qe_invalid;
7083 43520 }
7084 8704 }
7085
7086
2/2
✓ Branch 0 taken 66850 times.
✓ Branch 1 taken 42240 times.
109090 if ( s_version >= 60 )
7087 {
7088
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 4352 times.
42240 if ( s_version >= 65 )
7089 {
7090
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&tempitem.pickup_litems,f))
7091 return qe_invalid;
7092 37888 }
7093 else
7094 {
7095
1/2
✓ Branch 0 taken 4352 times.
✗ Branch 1 not taken.
4352 if(!p_getc(&padding,f))
7096 return qe_invalid;
7097 4352 tempitem.pickup_litems = word(padding);
7098 }
7099
1/2
✓ Branch 0 taken 42240 times.
✗ Branch 1 not taken.
42240 if(!p_igetw(&tempitem.pickup_litem_level,f))
7100 return qe_invalid;
7101 42240 }
7102
7103
2/2
✓ Branch 0 taken 42240 times.
✓ Branch 1 taken 66850 times.
109090 if ( s_version >= 62 )
7104 {
7105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42240 times.
42240 if (!p_igetl(&tempitem.moveflags, f))
7106 return qe_invalid;
7107
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 1536 times.
42240 if(s_version < 63)
7108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7109 return qe_invalid;
7110 42240 }
7111 else
7112 {
7113 66850 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7114
3/3
✓ Branch 0 taken 1924 times.
✓ Branch 1 taken 64625 times.
✓ Branch 2 taken 301 times.
66850 switch(tempitem.type)
7115 {
7116 case itype_divinefire:
7117
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 134 times.
301 if(!(tempitem.flags & item_flag3))
7118 134 break;
7119 [[fallthrough]];
7120 case itype_bomb: case itype_sbomb:
7121 case itype_bait: case itype_liftglove:
7122 case itype_candle: case itype_book:
7123 2091 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7124 2091 break;
7125 default:
7126 64625 tempitem.weap_data.moveflags = move_none;
7127 64625 break;
7128 }
7129 }
7130
7131
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 68386 times.
109090 if(s_version >= 63)
7132 {
7133
1/2
✓ Branch 0 taken 40704 times.
✗ Branch 1 not taken.
40704 if(auto ret = read_weap_data(tempitem.weap_data, f))
7134 return ret;
7135 40704 }
7136 else
7137 {
7138
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 68369 times.
68386 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7139
3/3
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 67692 times.
✓ Branch 2 taken 64 times.
68386 switch(tempitem.type)
7140 {
7141 case itype_liftglove:
7142 64 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7143 64 break;
7144 case itype_bomb: case itype_sbomb:
7145 // Moving these over and removing them from itemdata
7146
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 23 times.
630 if(tempitem.flags & item_flag3)
7147 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7148
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 23 times.
630 if(tempitem.flags & item_flag5)
7149 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7150 630 tempitem.flags &= ~(item_flag3|item_flag5);
7151
2/2
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 17 times.
630 if(tempitem.misc4)
7152 {
7153 17 tempitem.weap_data.lift_level = tempitem.misc4;
7154 17 tempitem.weap_data.lift_time = tempitem.misc5;
7155 17 tempitem.weap_data.lift_height = tempitem.misc6;
7156 17 tempitem.misc4 = 0;
7157 17 tempitem.misc5 = 0;
7158 17 tempitem.misc6 = 0;
7159 17 }
7160 630 break;
7161 }
7162 }
7163
7164
2/2
✓ Branch 0 taken 71202 times.
✓ Branch 1 taken 37888 times.
109090 if (s_version >= 64)
7165 {
7166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if (!p_igetl(&tempitem.cooldown, f))
7167 return qe_invalid;
7168 37888 }
7169
7170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109090 times.
109090 if (!should_skip)
7171 {
7172
1/2
✓ Branch 0 taken 109090 times.
✗ Branch 1 not taken.
109090 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7173 {
7174 tempitem.script = 0;
7175 tempitem.weap_data.script = 0;
7176 for(int q = 0; q < 8; ++q)
7177 {
7178 tempitem.initiald[q] = 0;
7179 tempitem.weap_data.initd[q] = 0;
7180 }
7181 }
7182 109090 itemsbuf[i] = tempitem;
7183 109090 }
7184 109090 }
7185
7186
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 492 times.
493 if (should_skip)
7187 1 return 0;
7188
7189 //////////////////////////////////////////////////////
7190 // Now do any updates because of new item additions
7191 // (These can't be done above because items_to_read
7192 // might be too low.)
7193 //////////////////////////////////////////////////////
7194
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<MAXITEMS; i++)
7195 {
7196 125952 tempitem = itemsbuf[i];
7197
7198 //Account for older quests that didn't have an actual item for the used letter
7199
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
125952 if(s_version < 2 && i==iLetterUsed)
7200 {
7201 82 reset_itembuf(&tempitem, iLetterUsed);
7202 82 strcpy(item_string[i],old_item_string[i]);
7203 82 tempitem.tile = itemsbuf[iLetter].tile;
7204 82 tempitem.csets = itemsbuf[iLetter].csets;
7205 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7206 82 tempitem.frames = itemsbuf[iLetter].frames;
7207 82 tempitem.speed = itemsbuf[iLetter].speed;
7208 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7209 82 }
7210
7211
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 3)
7212 {
7213
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7214 {
7215 case iRocsFeather:
7216 case iHoverBoots:
7217 case iSpinScroll:
7218 case iL2SpinScroll:
7219 case iCrossScroll:
7220 case iQuakeScroll:
7221 case iL2QuakeScroll:
7222 case iWhispRing:
7223 case iL2WhispRing:
7224 case iChargeRing:
7225 case iL2ChargeRing:
7226 case iPerilScroll:
7227 case iWalletL3:
7228 case iQuiverL4:
7229 case iBombBagL4:
7230 case iBracelet:
7231 case iL2Bracelet:
7232 case iOldGlove:
7233 case iL2Ladder:
7234 case iWealthMedal:
7235 case iL2WealthMedal:
7236 case iL3WealthMedal:
7237 1804 reset_itembuf(&tempitem, i);
7238 1804 strcpy(item_string[i],old_item_string[i]);
7239 1804 break;
7240
7241 case iSShield:
7242 82 reset_itembuf(&tempitem, i);
7243 82 strcpy(item_string[i],old_item_string[i]);
7244 82 strcpy(item_string[iShield],old_item_string[iShield]);
7245 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7246 82 break;
7247 }
7248 20992 }
7249
7250
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 5)
7251 {
7252
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7253 {
7254 case iHeartRing:
7255 case iL2HeartRing:
7256 case iL3HeartRing:
7257 case iMagicRing:
7258 case iL2MagicRing:
7259 case iL3MagicRing:
7260 case iL4MagicRing:
7261 574 reset_itembuf(&tempitem, i);
7262 574 strcpy(item_string[i],old_item_string[i]);
7263 574 break;
7264 }
7265 20992 }
7266
7267
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7268 {
7269
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7270
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7271
7272
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7273 {
7274 case iTriforce:
7275 82 tempitem.level=1;
7276 82 break;
7277
7278 case iBigTri:
7279 82 tempitem.level=0;
7280 82 break;
7281
7282 case iBombs:
7283 82 tempitem.level=i_bomb;
7284 82 tempitem.power=4;
7285 82 tempitem.wpn=wBOMB;
7286 82 tempitem.wpn2=wBOOM;
7287 82 tempitem.misc1 = 50;
7288
7289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7290
7291 82 break;
7292
7293 case iSBomb:
7294 82 tempitem.level=i_sbomb;
7295 82 tempitem.power=16;
7296 82 tempitem.wpn=wSBOMB;
7297 82 tempitem.wpn2=wSBOOM;
7298 82 tempitem.misc1 = 50;
7299
7300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7301
7302 82 break;
7303
7304 case iBook:
7305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7306 tempitem.wpn = wFIREMAGIC;
7307
7308 82 break;
7309
7310 case iSArrow:
7311 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7312 82 tempitem.power=4;
7313 82 tempitem.flags|=item_gamedata;
7314 82 tempitem.wpn=wSARROW;
7315 82 break;
7316
7317 case iGArrow:
7318 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7319 82 tempitem.power=8;
7320 82 tempitem.flags|=(item_gamedata|item_flag1);
7321 82 tempitem.wpn=wGARROW;
7322 82 break;
7323
7324 case iBrang:
7325 82 tempitem.power=0;
7326 82 tempitem.wpn=wBRANG;
7327 82 tempitem.misc1=36;
7328 82 break;
7329
7330 case iMBrang:
7331 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7332 82 tempitem.power=0;
7333 82 tempitem.wpn=wMBRANG;
7334 82 break;
7335
7336 case iFBrang:
7337 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7338 82 tempitem.power=2;
7339 82 tempitem.wpn=wFBRANG;
7340 82 break;
7341
7342 case iBoots:
7343 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7344 82 tempitem.power=7;
7345 82 break;
7346
7347 case iWand:
7348 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7349 82 tempitem.power=2;
7350 82 tempitem.wpn=wWAND;
7351 82 tempitem.wpn3=wMAGIC;
7352 82 break;
7353
7354 case iBCandle:
7355 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7356 82 tempitem.power=1;
7357 82 tempitem.flags|=(item_gamedata|item_flag1);
7358 82 tempitem.wpn3=wFIRE;
7359 82 break;
7360
7361 case iRCandle:
7362 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7363 82 tempitem.power=1;
7364 82 tempitem.wpn3=wFIRE;
7365 82 break;
7366
7367 case iSword:
7368 82 tempitem.power=1;
7369 82 tempitem.flags|= item_flag4 |item_flag2;
7370 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7371 82 tempitem.wpn2=wSWORDSLASH;
7372 82 break;
7373
7374 case iWSword:
7375 82 tempitem.power=2;
7376 82 tempitem.flags|= item_flag4 |item_flag2;
7377 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7378 82 tempitem.wpn2=wWSWORDSLASH;
7379 82 break;
7380
7381 case iMSword:
7382 82 tempitem.power=4;
7383 82 tempitem.flags|= item_flag4 |item_flag2;
7384 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7385 82 tempitem.wpn2=wMSWORDSLASH;
7386 82 break;
7387
7388 case iXSword:
7389 82 tempitem.power=8;
7390 82 tempitem.flags|= item_flag4 |item_flag2;
7391 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7392 82 tempitem.wpn2=wXSWORDSLASH;
7393 82 break;
7394
7395 case iDivineProtection:
7396 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7397 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7398 82 tempitem.wpn=wDIVINEPROTECTION1A;
7399 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7400 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7401 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7402 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7403 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7404 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7405 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7406 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7407 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7408 82 tempitem.misc1=512;
7409 82 tempitem.cost_amount[0]=64;
7410 82 break;
7411
7412 case iLens:
7413 82 tempitem.misc1=60;
7414 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7415 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7416 82 break;
7417
7418 case iArrow:
7419 82 tempitem.power=2;
7420 82 tempitem.wpn=wARROW;
7421 82 break;
7422
7423 case iHoverBoots:
7424 82 tempitem.misc1=45;
7425 82 tempitem.wpn=iwHover;
7426 82 break;
7427
7428 case iDivineFire:
7429 82 tempitem.power=8;
7430 82 tempitem.wpn=wDIVINEFIRE1A;
7431 82 tempitem.wpn2=wDIVINEFIRE1B;
7432 82 tempitem.wpn3=wDIVINEFIRES1A;
7433 82 tempitem.wpn4=wDIVINEFIRES1B;
7434 82 tempitem.misc1 = 32;
7435 82 tempitem.misc2 = 200;
7436 82 tempitem.cost_amount[0]=32;
7437 82 break;
7438
7439 case iDivineEscape:
7440 82 tempitem.cost_amount[0]=32;
7441 82 break;
7442
7443 case iHookshot:
7444 82 tempitem.power=0;
7445 82 tempitem.flags&=~item_flag1;
7446 82 tempitem.wpn=wHSHEAD;
7447 82 tempitem.wpn2=wHSCHAIN_H;
7448 82 tempitem.wpn4=wHSHANDLE;
7449 82 tempitem.wpn3=wHSCHAIN_V;
7450 82 tempitem.misc1=50;
7451 82 tempitem.misc2=100;
7452 82 break;
7453
7454 case iLongshot:
7455 82 tempitem.power=0;
7456 82 tempitem.flags&=~item_flag1;
7457 82 tempitem.wpn=wLSHEAD;
7458 82 tempitem.wpn2=wLSCHAIN_H;
7459 82 tempitem.wpn4=wLSHANDLE;
7460 82 tempitem.wpn3=wLSCHAIN_V;
7461 82 tempitem.misc1=99;
7462 82 tempitem.misc2=100;
7463 82 break;
7464
7465 case iHammer:
7466 82 tempitem.power=4;
7467 82 tempitem.wpn=wHAMMER;
7468 82 tempitem.wpn2=iwHammerSmack;
7469 82 break;
7470
7471 case iCByrna:
7472 82 tempitem.power=1;
7473 82 tempitem.wpn=wCBYRNA;
7474 82 tempitem.wpn2=wCBYRNASLASH;
7475 82 tempitem.wpn3=wCBYRNAORB;
7476 82 tempitem.misc1=4;
7477 82 tempitem.misc2=16;
7478 82 tempitem.misc3=1;
7479 82 tempitem.cost_amount[0]=1;
7480 82 break;
7481
7482 case iWhistle:
7483 82 tempitem.wpn=wWIND;
7484 82 tempitem.misc1=3;
7485 82 tempitem.flags|=item_flag1;
7486 82 break;
7487
7488 case iBRing:
7489 82 tempitem.power=2;
7490 82 tempitem.misc1=spBLUE;
7491 82 break;
7492
7493 case iRRing:
7494 82 tempitem.power=4;
7495 82 tempitem.misc1=spRED;
7496 82 break;
7497
7498 case iGRing:
7499 82 tempitem.power=8;
7500 82 tempitem.misc1=spGOLD;
7501 82 break;
7502
7503 case iSpinScroll:
7504 82 tempitem.power = 2;
7505 82 tempitem.misc1 = 1;
7506 82 break;
7507
7508 case iL2SpinScroll:
7509 82 tempitem.type=itype_spinscroll2;
7510 82 tempitem.level=1;
7511 82 tempitem.cost_amount[0]=8;
7512 82 tempitem.power=2;
7513 82 tempitem.misc1 = 20;
7514 82 break;
7515
7516 case iQuakeScroll:
7517 82 tempitem.misc1=0x10;
7518 82 tempitem.misc2=64;
7519 82 break;
7520
7521 case iL2QuakeScroll:
7522 82 tempitem.type=itype_quakescroll2;
7523 82 tempitem.level=1;
7524 82 tempitem.power = 2;
7525 82 tempitem.misc1=0x20;
7526 82 tempitem.misc2=192;
7527 82 tempitem.cost_amount[0]=8;
7528 82 break;
7529
7530 case iChargeRing:
7531 82 tempitem.misc1=64;
7532 82 tempitem.misc2=128;
7533 82 break;
7534
7535 case iL2ChargeRing:
7536 82 tempitem.misc1=32;
7537 82 tempitem.misc2=64;
7538 82 break;
7539
7540 case iOldGlove:
7541 82 tempitem.flags |= item_flag1;
7542
7543 //fallthrough
7544 case iBombBagL4:
7545 case iWalletL3:
7546 case iQuiverL4:
7547 case iBracelet:
7548 410 tempitem.power = 1;
7549 410 break;
7550
7551 case iL2Bracelet:
7552 82 tempitem.power = 2;
7553 82 break;
7554
7555 case iMKey:
7556 82 tempitem.power=0xFF;
7557 82 tempitem.flags |= item_flag1;
7558 82 break;
7559 }
7560 20992 }
7561
7562
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 7)
7563 {
7564
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7565 {
7566 case iStoneAgony:
7567 case iStompBoots:
7568 case iPerilRing:
7569 case iWhimsicalRing:
7570 {
7571 328 reset_itembuf(&tempitem, i);
7572 328 strcpy(item_string[i],old_item_string[i]);
7573 328 break;
7574 }
7575 }
7576 20992 }
7577
7578
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 8) // May 2007: Some corrections.
7579 {
7580
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7581 {
7582 case iMShield:
7583 82 tempitem.misc1|=sh_flame;
7584 82 tempitem.misc2|=sh_fireball|sh_magic;
7585
7586
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7587 {
7588 tempitem.misc2 |= sh_sword;
7589 }
7590
7591 // fallthrough
7592 case iShield:
7593 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7594
7595 // fallthrough
7596 case iSShield:
7597 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7598
7599
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7600 {
7601 tempitem.misc2 |= sh_rock;
7602 }
7603
7604 246 break;
7605
7606 case iWhispRing:
7607 82 tempitem.power=1;
7608 82 tempitem.flags|=item_gamedata|item_flag1;
7609 82 tempitem.misc1 = 3;
7610 82 break;
7611
7612 case iL2WhispRing:
7613 82 tempitem.power=0;
7614 82 tempitem.flags|=item_gamedata|item_flag1;
7615 82 tempitem.misc1 = 3;
7616 82 break;
7617
7618 case iL2Ladder:
7619 case iBow:
7620 case iCByrna:
7621 246 tempitem.power = 1;
7622 246 break;
7623 }
7624 20992 }
7625
7626
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
125952 if(s_version < 9 && i==iClock)
7627 {
7628 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7629 82 }
7630
7631 //add the misc flag for bomb
7632
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
125952 if(s_version < 10 && tempitem.type == itype_bomb)
7633 {
7634 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7635 82 }
7636
7637
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
125952 if(s_version < 11 && tempitem.type == itype_triforcepiece)
7638 {
7639 164 tempitem.flags = (tempitem.level ? item_gamedata : item_none);
7640 164 tempitem.playsound = (tempitem.level ? WAV_SCALE : WAV_CLEARED);
7641 164 }
7642
7643
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 12) // June 2007: More Misc. attributes.
7644 {
7645
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7646 {
7647 case iFBrang:
7648 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7649
7650 //fallthrough
7651 case iMBrang:
7652 164 tempitem.misc3 |= sh_sword|sh_magic;
7653
7654 //fallthrough
7655 case iHookshot:
7656 case iLongshot:
7657 //fallthrough
7658 328 tempitem.misc3 |= sh_fireball;
7659
7660 case iBrang:
7661 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7662 410 break;
7663 }
7664
7665
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 328 times.
✓ Branch 10 taken 164 times.
✓ Branch 11 taken 9629 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.type)
7666 {
7667 case itype_hoverboots:
7668 82 tempitem.usesound = WAV_ZN1HOVER;
7669 82 break;
7670
7671 case itype_wand:
7672 82 tempitem.usesound = WAV_WAND;
7673 82 break;
7674
7675 case itype_book:
7676 82 tempitem.usesound = WAV_FIRE;
7677 82 break;
7678
7679 case itype_arrow:
7680 246 tempitem.usesound = WAV_ARROW;
7681 246 break;
7682
7683 case itype_hookshot:
7684 164 tempitem.usesound = WAV_HOOKSHOT;
7685 164 break;
7686
7687 case itype_brang:
7688 246 tempitem.usesound = WAV_BRANG;
7689 246 break;
7690
7691 case itype_shield:
7692 246 tempitem.usesound = WAV_CHINK;
7693 246 break;
7694
7695 case itype_sword:
7696 9313 tempitem.usesound = WAV_SWORD;
7697 9313 break;
7698
7699 case itype_whistle:
7700 82 tempitem.usesound = WAV_WHISTLE;
7701 82 break;
7702
7703 case itype_hammer:
7704 82 tempitem.usesound = WAV_HAMMER;
7705 82 break;
7706
7707 case itype_divinefire:
7708 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7709 82 break;
7710
7711 case itype_divineescape:
7712 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7713 82 break;
7714
7715 case itype_divineprotection:
7716 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7717 82 break;
7718
7719 case itype_bomb:
7720 case itype_sbomb:
7721 case itype_quakescroll:
7722 case itype_quakescroll2:
7723 328 tempitem.usesound = WAV_BOMB;
7724 328 break;
7725
7726 case itype_spinscroll:
7727 case itype_spinscroll2:
7728 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7729 164 break;
7730 }
7731 20992 }
7732
7733
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 13) // July 2007
7734 {
7735
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7736 {
7737 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7738 82 tempitem.power = 1;
7739 82 tempitem.flags|=item_flag1;
7740 82 }
7741
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_wand)
7742 82 tempitem.flags|=item_flag1;
7743
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.type == itype_book)
7744 {
7745 82 tempitem.flags|=item_flag1;
7746 82 tempitem.power = 2;
7747 82 }
7748 20992 }
7749
7750
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 14) // August 2007
7751 {
7752
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.type == itype_fairy)
7753 {
7754 164 tempitem.usesound = WAV_SCALE;
7755
7756
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.level)
7757 164 tempitem.misc3=50;
7758 164 }
7759
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_potion)
7760 {
7761 164 tempitem.flags |= item_gain_old;
7762 164 }
7763 20992 }
7764
7765
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 17) // November 2007
7766 {
7767
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.type == itype_candle && !tempitem.wpn3)
7768 {
7769 tempitem.wpn3 = wFIRE;
7770 }
7771
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.type == itype_arrow && tempitem.power>4)
7772 {
7773 82 tempitem.flags|=item_flag1;
7774 82 }
7775 20992 }
7776
7777
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 18) // New Year's Eve 2007
7778 {
7779
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7780 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7781
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_bait)
7782 82 tempitem.misc1 = 768; // Frames until it goes
7783
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_triforcepiece)
7784 {
7785
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7786 {
7787 82 tempitem.misc2 = 1; // Cutscene 1
7788 82 tempitem.flags |= item_flag1; // Side Warp Out
7789 82 }
7790 164 }
7791 20992 }
7792
7793
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 19) // January 2008
7794 {
7795
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7796 {
7797
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7798
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7799 82 }
7800 20992 }
7801
7802
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 20) // October 2008
7803 {
7804
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7805 {
7806 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7807 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7808 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7809 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7810 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7811 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7812 82 }
7813 20992 }
7814
7815
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 21) // November 2008
7816 {
7817
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7818 {
7819 tempitem.flags &= ~item_unused;
7820
7821 if(tempitem.type == itype_sword ||
7822 tempitem.type == itype_wand ||
7823 tempitem.type == itype_candle ||
7824 tempitem.type == itype_cbyrna)
7825 {
7826 tempitem.flags |= item_flag4;
7827 }
7828 }
7829 20992 }
7830
7831
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 22) // September 2009
7832 {
7833
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.type == itype_sbomb || tempitem.type == itype_bomb)
7834 {
7835 164 tempitem.misc3 = tempitem.power/2;
7836 164 }
7837 20992 }
7838
7839
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 23) // March 2011
7840 {
7841
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_divinefire)
7842 82 tempitem.wpn5 = wFIRE;
7843
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.type == itype_book)
7844 82 tempitem.wpn2 = wFIRE;
7845 20992 }
7846
7847 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7848 // whether it was or not, and a lot of existing quests depended on the
7849 // incorrect behavior.
7850
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 20992 times.
125952 if(s_version < 25) // January 2012
7851 {
7852
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.type == itype_bombbag)
7853 328 tempitem.flags |= item_flag1;
7854
7855
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divinefire)
7856 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7857 20992 }
7858
7859
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7860 {
7861
60/60
✓ Branch 0 taken 17547 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 327 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 558 times.
✓ Branch 7 taken 614 times.
✓ Branch 8 taken 297 times.
✓ Branch 9 taken 917 times.
✓ Branch 10 taken 892 times.
✓ Branch 11 taken 557 times.
✓ Branch 12 taken 858 times.
✓ Branch 13 taken 558 times.
✓ Branch 14 taken 279 times.
✓ Branch 15 taken 558 times.
✓ Branch 16 taken 295 times.
✓ Branch 17 taken 279 times.
✓ Branch 18 taken 846 times.
✓ Branch 19 taken 282 times.
✓ Branch 20 taken 285 times.
✓ Branch 21 taken 560 times.
✓ Branch 22 taken 255 times.
✓ Branch 23 taken 282 times.
✓ Branch 24 taken 279 times.
✓ Branch 25 taken 279 times.
✓ Branch 26 taken 279 times.
✓ Branch 27 taken 295 times.
✓ Branch 28 taken 281 times.
✓ Branch 29 taken 282 times.
✓ Branch 30 taken 279 times.
✓ Branch 31 taken 284 times.
✓ Branch 32 taken 558 times.
✓ Branch 33 taken 1116 times.
✓ Branch 34 taken 780 times.
✓ Branch 35 taken 279 times.
✓ Branch 36 taken 545 times.
✓ Branch 37 taken 1116 times.
✓ Branch 38 taken 279 times.
✓ Branch 39 taken 279 times.
✓ Branch 40 taken 279 times.
✓ Branch 41 taken 279 times.
✓ Branch 42 taken 279 times.
✓ Branch 43 taken 561 times.
✓ Branch 44 taken 558 times.
✓ Branch 45 taken 279 times.
✓ Branch 46 taken 840 times.
✓ Branch 47 taken 843 times.
✓ Branch 48 taken 1128 times.
✓ Branch 49 taken 279 times.
✓ Branch 50 taken 279 times.
✓ Branch 51 taken 279 times.
✓ Branch 52 taken 279 times.
✓ Branch 53 taken 279 times.
✓ Branch 54 taken 306 times.
✓ Branch 55 taken 10652 times.
✓ Branch 56 taken 2872 times.
✓ Branch 57 taken 842 times.
✓ Branch 58 taken 3261 times.
✓ Branch 59 taken 11005 times.
72192 switch(tempitem.type)
7862 {
7863 case itype_sword:
7864 {
7865 17547 tempitem.flags &= ~(item_flag5);
7866 17547 tempitem.misc3 = 0;
7867 17547 tempitem.misc4 = 0;
7868 17547 tempitem.misc5 = 0;
7869 17547 tempitem.misc6 = 0;
7870 17547 tempitem.misc7 = 0;
7871 17547 tempitem.misc8 = 0;
7872 17547 tempitem.misc9 = 0;
7873 17547 tempitem.misc10 = 0;
7874 17547 tempitem.wpn4 = 0;
7875 17547 tempitem.wpn5 = 0;
7876 17547 tempitem.wpn6 = 0;
7877 17547 tempitem.wpn7 = 0;
7878 17547 tempitem.wpn8 = 0;
7879 17547 tempitem.wpn9 = 0;
7880 17547 tempitem.wpn10 = 0;
7881 17547 break;
7882 }
7883 case itype_brang:
7884 {
7885 844 tempitem.flags &= ~(item_flag4 | item_flag5);
7886 844 tempitem.misc2 = 0;
7887 844 tempitem.misc5 = 0;
7888 844 tempitem.misc6 = 0;
7889 844 tempitem.misc7 = 0;
7890 844 tempitem.misc8 = 0;
7891 844 tempitem.misc9 = 0;
7892 844 tempitem.misc10 = 0;
7893 844 tempitem.wpn4 = 0;
7894 844 tempitem.wpn5 = 0;
7895 844 tempitem.wpn6 = 0;
7896 844 tempitem.wpn7 = 0;
7897 844 tempitem.wpn8 = 0;
7898 844 tempitem.wpn9 = 0;
7899 844 tempitem.wpn10 = 0;
7900 844 break;
7901 }
7902 case itype_arrow:
7903 {
7904 831 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7905 831 tempitem.misc2 = 0;
7906 831 tempitem.misc3 = 0;
7907 831 tempitem.misc4 = 0;
7908 831 tempitem.misc5 = 0;
7909 831 tempitem.misc6 = 0;
7910 831 tempitem.misc7 = 0;
7911 831 tempitem.misc8 = 0;
7912 831 tempitem.misc9 = 0;
7913 831 tempitem.misc10 = 0;
7914 831 tempitem.wpn4 = 0;
7915 831 tempitem.wpn5 = 0;
7916 831 tempitem.wpn6 = 0;
7917 831 tempitem.wpn7 = 0;
7918 831 tempitem.wpn8 = 0;
7919 831 tempitem.wpn9 = 0;
7920 831 tempitem.wpn10 = 0;
7921 831 break;
7922 }
7923 case itype_candle:
7924 {
7925 600 tempitem.flags &= ~ (item_flag3 | item_flag5);
7926 600 tempitem.misc1 = 0;
7927 600 tempitem.misc2 = 0;
7928 600 tempitem.misc3 = 0;
7929 600 tempitem.misc4 = 0;
7930 600 tempitem.misc5 = 0;
7931 600 tempitem.misc6 = 0;
7932 600 tempitem.misc7 = 0;
7933 600 tempitem.misc8 = 0;
7934 600 tempitem.misc9 = 0;
7935 600 tempitem.misc10 = 0;
7936 600 tempitem.wpn4 = 0;
7937 600 tempitem.wpn5 = 0;
7938 600 tempitem.wpn6 = 0;
7939 600 tempitem.wpn7 = 0;
7940 600 tempitem.wpn8 = 0;
7941 600 tempitem.wpn9 = 0;
7942 600 tempitem.wpn10 = 0;
7943 600 break;
7944 }
7945 case itype_whistle:
7946 {
7947 327 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7948 327 tempitem.misc3 = 0;
7949 327 tempitem.misc4 = 0;
7950 327 tempitem.misc5 = 0;
7951 327 tempitem.misc6 = 0;
7952 327 tempitem.misc7 = 0;
7953 327 tempitem.misc8 = 0;
7954 327 tempitem.misc9 = 0;
7955 327 tempitem.misc10 = 0;
7956 327 tempitem.wpn2 = 0;
7957 327 tempitem.wpn3 = 0;
7958 327 tempitem.wpn4 = 0;
7959 327 tempitem.wpn5 = 0;
7960 327 tempitem.wpn6 = 0;
7961 327 tempitem.wpn7 = 0;
7962 327 tempitem.wpn8 = 0;
7963 327 tempitem.wpn9 = 0;
7964 327 tempitem.wpn10 = 0;
7965 327 break;
7966 }
7967 case itype_bait:
7968 {
7969 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7970 282 tempitem.misc2 = 0;
7971 282 tempitem.misc3 = 0;
7972 282 tempitem.misc4 = 0;
7973 282 tempitem.misc5 = 0;
7974 282 tempitem.misc6 = 0;
7975 282 tempitem.misc7 = 0;
7976 282 tempitem.misc8 = 0;
7977 282 tempitem.misc9 = 0;
7978 282 tempitem.misc10 = 0;
7979 282 tempitem.wpn2 = 0;
7980 282 tempitem.wpn3 = 0;
7981 282 tempitem.wpn4 = 0;
7982 282 tempitem.wpn5 = 0;
7983 282 tempitem.wpn6 = 0;
7984 282 tempitem.wpn7 = 0;
7985 282 tempitem.wpn8 = 0;
7986 282 tempitem.wpn9 = 0;
7987 282 tempitem.wpn10 = 0;
7988 282 break;
7989 }
7990 case itype_letter:
7991 {
7992 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7993 558 tempitem.misc1 = 0;
7994 558 tempitem.misc2 = 0;
7995 558 tempitem.misc3 = 0;
7996 558 tempitem.misc4 = 0;
7997 558 tempitem.misc5 = 0;
7998 558 tempitem.misc6 = 0;
7999 558 tempitem.misc7 = 0;
8000 558 tempitem.misc8 = 0;
8001 558 tempitem.misc9 = 0;
8002 558 tempitem.misc10 = 0;
8003 558 tempitem.wpn = 0;
8004 558 tempitem.wpn2 = 0;
8005 558 tempitem.wpn3 = 0;
8006 558 tempitem.wpn4 = 0;
8007 558 tempitem.wpn5 = 0;
8008 558 tempitem.wpn6 = 0;
8009 558 tempitem.wpn7 = 0;
8010 558 tempitem.wpn8 = 0;
8011 558 tempitem.wpn9 = 0;
8012 558 tempitem.wpn10 = 0;
8013 558 break;
8014 }
8015 case itype_potion:
8016 {
8017 614 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8018 614 tempitem.misc3 = 0;
8019 614 tempitem.misc4 = 0;
8020 614 tempitem.misc5 = 0;
8021 614 tempitem.misc6 = 0;
8022 614 tempitem.misc7 = 0;
8023 614 tempitem.misc8 = 0;
8024 614 tempitem.misc9 = 0;
8025 614 tempitem.misc10 = 0;
8026 614 tempitem.wpn = 0;
8027 614 tempitem.wpn2 = 0;
8028 614 tempitem.wpn3 = 0;
8029 614 tempitem.wpn4 = 0;
8030 614 tempitem.wpn5 = 0;
8031 614 tempitem.wpn6 = 0;
8032 614 tempitem.wpn7 = 0;
8033 614 tempitem.wpn8 = 0;
8034 614 tempitem.wpn9 = 0;
8035 614 tempitem.wpn10 = 0;
8036 614 break;
8037 }
8038 case itype_wand:
8039 {
8040 297 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8041 297 tempitem.misc1 = 0;
8042 297 tempitem.misc2 = 0;
8043 297 tempitem.misc3 = 0;
8044 297 tempitem.misc4 = 0;
8045 297 tempitem.misc5 = 0;
8046 297 tempitem.misc6 = 0;
8047 297 tempitem.misc7 = 0;
8048 297 tempitem.misc8 = 0;
8049 297 tempitem.misc9 = 0;
8050 297 tempitem.misc10 = 0;
8051 297 tempitem.wpn4 = 0;
8052 297 tempitem.wpn5 = 0;
8053 297 tempitem.wpn6 = 0;
8054 297 tempitem.wpn7 = 0;
8055 297 tempitem.wpn8 = 0;
8056 297 tempitem.wpn9 = 0;
8057 297 tempitem.wpn10 = 0;
8058 297 break;
8059 }
8060 case itype_ring:
8061 {
8062 917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8063 917 tempitem.misc2 = 0;
8064 917 tempitem.misc3 = 0;
8065 917 tempitem.misc4 = 0;
8066 917 tempitem.misc5 = 0;
8067 917 tempitem.misc6 = 0;
8068 917 tempitem.misc7 = 0;
8069 917 tempitem.misc8 = 0;
8070 917 tempitem.misc9 = 0;
8071 917 tempitem.misc10 = 0;
8072 917 tempitem.wpn = 0;
8073 917 tempitem.wpn2 = 0;
8074 917 tempitem.wpn3 = 0;
8075 917 tempitem.wpn4 = 0;
8076 917 tempitem.wpn5 = 0;
8077 917 tempitem.wpn6 = 0;
8078 917 tempitem.wpn7 = 0;
8079 917 tempitem.wpn8 = 0;
8080 917 tempitem.wpn9 = 0;
8081 917 tempitem.wpn10 = 0;
8082 917 break;
8083 }
8084 case itype_wallet:
8085 {
8086 892 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8087 892 tempitem.misc3 = 0;
8088 892 tempitem.misc4 = 0;
8089 892 tempitem.misc5 = 0;
8090 892 tempitem.misc6 = 0;
8091 892 tempitem.misc7 = 0;
8092 892 tempitem.misc8 = 0;
8093 892 tempitem.misc9 = 0;
8094 892 tempitem.misc10 = 0;
8095 892 tempitem.wpn = 0;
8096 892 tempitem.wpn2 = 0;
8097 892 tempitem.wpn3 = 0;
8098 892 tempitem.wpn4 = 0;
8099 892 tempitem.wpn5 = 0;
8100 892 tempitem.wpn6 = 0;
8101 892 tempitem.wpn7 = 0;
8102 892 tempitem.wpn8 = 0;
8103 892 tempitem.wpn9 = 0;
8104 892 tempitem.wpn10 = 0;
8105 892 break;
8106 }
8107 case itype_amulet:
8108 {
8109 557 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8110 557 tempitem.misc1 = 0;
8111 557 tempitem.misc2 = 0;
8112 557 tempitem.misc3 = 0;
8113 557 tempitem.misc4 = 0;
8114 557 tempitem.misc5 = 0;
8115 557 tempitem.misc6 = 0;
8116 557 tempitem.misc7 = 0;
8117 557 tempitem.misc8 = 0;
8118 557 tempitem.misc9 = 0;
8119 557 tempitem.misc10 = 0;
8120 557 tempitem.wpn = 0;
8121 557 tempitem.wpn2 = 0;
8122 557 tempitem.wpn3 = 0;
8123 557 tempitem.wpn4 = 0;
8124 557 tempitem.wpn5 = 0;
8125 557 tempitem.wpn6 = 0;
8126 557 tempitem.wpn7 = 0;
8127 557 tempitem.wpn8 = 0;
8128 557 tempitem.wpn9 = 0;
8129 557 tempitem.wpn10 = 0;
8130 557 break;
8131 }
8132 case itype_shield:
8133 {
8134 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8135 858 tempitem.misc3 = 0;
8136 858 tempitem.misc4 = 0;
8137 858 tempitem.misc5 = 0;
8138 858 tempitem.misc6 = 0;
8139 858 tempitem.misc7 = 0;
8140 858 tempitem.misc8 = 0;
8141 858 tempitem.misc9 = 0;
8142 858 tempitem.misc10 = 0;
8143 858 tempitem.wpn = 0;
8144 858 tempitem.wpn2 = 0;
8145 858 tempitem.wpn3 = 0;
8146 858 tempitem.wpn4 = 0;
8147 858 tempitem.wpn5 = 0;
8148 858 tempitem.wpn6 = 0;
8149 858 tempitem.wpn7 = 0;
8150 858 tempitem.wpn8 = 0;
8151 858 tempitem.wpn9 = 0;
8152 858 tempitem.wpn10 = 0;
8153 858 break;
8154 }
8155 case itype_bow:
8156 {
8157 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8158 558 tempitem.misc1 = 0;
8159 558 tempitem.misc2 = 0;
8160 558 tempitem.misc3 = 0;
8161 558 tempitem.misc4 = 0;
8162 558 tempitem.misc5 = 0;
8163 558 tempitem.misc6 = 0;
8164 558 tempitem.misc7 = 0;
8165 558 tempitem.misc8 = 0;
8166 558 tempitem.misc9 = 0;
8167 558 tempitem.misc10 = 0;
8168 558 tempitem.wpn = 0;
8169 558 tempitem.wpn2 = 0;
8170 558 tempitem.wpn3 = 0;
8171 558 tempitem.wpn4 = 0;
8172 558 tempitem.wpn5 = 0;
8173 558 tempitem.wpn6 = 0;
8174 558 tempitem.wpn7 = 0;
8175 558 tempitem.wpn8 = 0;
8176 558 tempitem.wpn9 = 0;
8177 558 tempitem.wpn10 = 0;
8178 558 break;
8179 }
8180 case itype_raft:
8181 {
8182 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8183 279 tempitem.misc1 = 0;
8184 279 tempitem.misc2 = 0;
8185 279 tempitem.misc3 = 0;
8186 279 tempitem.misc4 = 0;
8187 279 tempitem.misc5 = 0;
8188 279 tempitem.misc6 = 0;
8189 279 tempitem.misc7 = 0;
8190 279 tempitem.misc8 = 0;
8191 279 tempitem.misc9 = 0;
8192 279 tempitem.misc10 = 0;
8193 279 tempitem.wpn = 0;
8194 279 tempitem.wpn2 = 0;
8195 279 tempitem.wpn3 = 0;
8196 279 tempitem.wpn4 = 0;
8197 279 tempitem.wpn5 = 0;
8198 279 tempitem.wpn6 = 0;
8199 279 tempitem.wpn7 = 0;
8200 279 tempitem.wpn8 = 0;
8201 279 tempitem.wpn9 = 0;
8202 279 tempitem.wpn10 = 0;
8203 279 break;
8204 }
8205 case itype_ladder:
8206 {
8207 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8208 558 tempitem.misc1 = 0;
8209 558 tempitem.misc2 = 0;
8210 558 tempitem.misc3 = 0;
8211 558 tempitem.misc4 = 0;
8212 558 tempitem.misc5 = 0;
8213 558 tempitem.misc6 = 0;
8214 558 tempitem.misc7 = 0;
8215 558 tempitem.misc8 = 0;
8216 558 tempitem.misc9 = 0;
8217 558 tempitem.misc10 = 0;
8218 558 tempitem.wpn = 0;
8219 558 tempitem.wpn2 = 0;
8220 558 tempitem.wpn3 = 0;
8221 558 tempitem.wpn4 = 0;
8222 558 tempitem.wpn5 = 0;
8223 558 tempitem.wpn6 = 0;
8224 558 tempitem.wpn7 = 0;
8225 558 tempitem.wpn8 = 0;
8226 558 tempitem.wpn9 = 0;
8227 558 tempitem.wpn10 = 0;
8228 558 break;
8229 }
8230 case itype_book:
8231 {
8232 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8233 295 tempitem.misc1 = 0;
8234 295 tempitem.misc2 = 0;
8235 295 tempitem.misc3 = 0;
8236 295 tempitem.misc4 = 0;
8237 295 tempitem.misc5 = 0;
8238 295 tempitem.misc6 = 0;
8239 295 tempitem.misc7 = 0;
8240 295 tempitem.misc8 = 0;
8241 295 tempitem.misc9 = 0;
8242 295 tempitem.misc10 = 0;
8243 295 tempitem.wpn3 = 0;
8244 295 tempitem.wpn4 = 0;
8245 295 tempitem.wpn5 = 0;
8246 295 tempitem.wpn6 = 0;
8247 295 tempitem.wpn7 = 0;
8248 295 tempitem.wpn8 = 0;
8249 295 tempitem.wpn9 = 0;
8250 295 tempitem.wpn10 = 0;
8251 295 break;
8252 }
8253 case itype_magickey:
8254 {
8255 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8256 279 tempitem.misc1 = 0;
8257 279 tempitem.misc2 = 0;
8258 279 tempitem.misc3 = 0;
8259 279 tempitem.misc4 = 0;
8260 279 tempitem.misc5 = 0;
8261 279 tempitem.misc6 = 0;
8262 279 tempitem.misc7 = 0;
8263 279 tempitem.misc8 = 0;
8264 279 tempitem.misc9 = 0;
8265 279 tempitem.misc10 = 0;
8266 279 tempitem.wpn = 0;
8267 279 tempitem.wpn2 = 0;
8268 279 tempitem.wpn3 = 0;
8269 279 tempitem.wpn4 = 0;
8270 279 tempitem.wpn5 = 0;
8271 279 tempitem.wpn6 = 0;
8272 279 tempitem.wpn7 = 0;
8273 279 tempitem.wpn8 = 0;
8274 279 tempitem.wpn9 = 0;
8275 279 tempitem.wpn10 = 0;
8276 279 break;
8277 }
8278 case itype_bracelet:
8279 {
8280 846 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8281 846 tempitem.misc1 = 0;
8282 846 tempitem.misc2 = 0;
8283 846 tempitem.misc3 = 0;
8284 846 tempitem.misc4 = 0;
8285 846 tempitem.misc5 = 0;
8286 846 tempitem.misc6 = 0;
8287 846 tempitem.misc7 = 0;
8288 846 tempitem.misc8 = 0;
8289 846 tempitem.misc9 = 0;
8290 846 tempitem.misc10 = 0;
8291 846 tempitem.wpn = 0;
8292 846 tempitem.wpn2 = 0;
8293 846 tempitem.wpn3 = 0;
8294 846 tempitem.wpn4 = 0;
8295 846 tempitem.wpn5 = 0;
8296 846 tempitem.wpn6 = 0;
8297 846 tempitem.wpn7 = 0;
8298 846 tempitem.wpn8 = 0;
8299 846 tempitem.wpn9 = 0;
8300 846 tempitem.wpn10 = 0;
8301 846 break;
8302 }
8303 case itype_flippers:
8304 {
8305 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8306 282 tempitem.misc1 = 0;
8307 282 tempitem.misc2 = 0;
8308 282 tempitem.misc3 = 0;
8309 282 tempitem.misc4 = 0;
8310 282 tempitem.misc5 = 0;
8311 282 tempitem.misc6 = 0;
8312 282 tempitem.misc7 = 0;
8313 282 tempitem.misc8 = 0;
8314 282 tempitem.misc9 = 0;
8315 282 tempitem.misc10 = 0;
8316 282 tempitem.wpn = 0;
8317 282 tempitem.wpn2 = 0;
8318 282 tempitem.wpn3 = 0;
8319 282 tempitem.wpn4 = 0;
8320 282 tempitem.wpn5 = 0;
8321 282 tempitem.wpn6 = 0;
8322 282 tempitem.wpn7 = 0;
8323 282 tempitem.wpn8 = 0;
8324 282 tempitem.wpn9 = 0;
8325 282 tempitem.wpn10 = 0;
8326 282 break;
8327 }
8328 case itype_boots:
8329 {
8330 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8331 285 tempitem.misc1 = 0;
8332 285 tempitem.misc2 = 0;
8333 285 tempitem.misc3 = 0;
8334 285 tempitem.misc4 = 0;
8335 285 tempitem.misc5 = 0;
8336 285 tempitem.misc6 = 0;
8337 285 tempitem.misc7 = 0;
8338 285 tempitem.misc8 = 0;
8339 285 tempitem.misc9 = 0;
8340 285 tempitem.misc10 = 0;
8341 285 tempitem.wpn = 0;
8342 285 tempitem.wpn2 = 0;
8343 285 tempitem.wpn3 = 0;
8344 285 tempitem.wpn4 = 0;
8345 285 tempitem.wpn5 = 0;
8346 285 tempitem.wpn6 = 0;
8347 285 tempitem.wpn7 = 0;
8348 285 tempitem.wpn8 = 0;
8349 285 tempitem.wpn9 = 0;
8350 285 tempitem.wpn10 = 0;
8351 285 break;
8352 }
8353 case itype_hookshot:
8354 {
8355 560 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8356 560 tempitem.misc5 = 0;
8357 560 tempitem.misc6 = 0;
8358 560 tempitem.misc7 = 0;
8359 560 tempitem.misc8 = 0;
8360 560 tempitem.misc9 = 0;
8361 560 tempitem.misc10 = 0;
8362 560 tempitem.wpn5 = 0;
8363 560 tempitem.wpn6 = 0;
8364 560 tempitem.wpn7 = 0;
8365 560 tempitem.wpn8 = 0;
8366 560 tempitem.wpn9 = 0;
8367 560 tempitem.wpn10 = 0;
8368 560 break;
8369 }
8370 case itype_lens:
8371 {
8372 255 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8373 255 tempitem.misc2 = 0;
8374 255 tempitem.misc3 = 0;
8375 255 tempitem.misc4 = 0;
8376 255 tempitem.misc5 = 0;
8377 255 tempitem.misc6 = 0;
8378 255 tempitem.misc7 = 0;
8379 255 tempitem.misc8 = 0;
8380 255 tempitem.misc9 = 0;
8381 255 tempitem.misc10 = 0;
8382 255 tempitem.wpn = 0;
8383 255 tempitem.wpn2 = 0;
8384 255 tempitem.wpn3 = 0;
8385 255 tempitem.wpn4 = 0;
8386 255 tempitem.wpn5 = 0;
8387 255 tempitem.wpn6 = 0;
8388 255 tempitem.wpn7 = 0;
8389 255 tempitem.wpn8 = 0;
8390 255 tempitem.wpn9 = 0;
8391 255 tempitem.wpn10 = 0;
8392 255 break;
8393 }
8394 case itype_hammer:
8395 {
8396 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8397 282 tempitem.misc1 = 0;
8398 282 tempitem.misc2 = 0;
8399 282 tempitem.misc3 = 0;
8400 282 tempitem.misc4 = 0;
8401 282 tempitem.misc5 = 0;
8402 282 tempitem.misc6 = 0;
8403 282 tempitem.misc7 = 0;
8404 282 tempitem.misc8 = 0;
8405 282 tempitem.misc9 = 0;
8406 282 tempitem.misc10 = 0;
8407 282 tempitem.wpn3 = 0;
8408 282 tempitem.wpn4 = 0;
8409 282 tempitem.wpn5 = 0;
8410 282 tempitem.wpn6 = 0;
8411 282 tempitem.wpn7 = 0;
8412 282 tempitem.wpn8 = 0;
8413 282 tempitem.wpn9 = 0;
8414 282 tempitem.wpn10 = 0;
8415 282 break;
8416 }
8417 case itype_divinefire:
8418 {
8419 279 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8420 279 tempitem.misc3 = 0;
8421 279 tempitem.misc4 = 0;
8422 279 tempitem.misc5 = 0;
8423 279 tempitem.misc6 = 0;
8424 279 tempitem.misc7 = 0;
8425 279 tempitem.misc8 = 0;
8426 279 tempitem.misc9 = 0;
8427 279 tempitem.misc10 = 0;
8428 279 tempitem.wpn6 = 0;
8429 279 tempitem.wpn7 = 0;
8430 279 tempitem.wpn8 = 0;
8431 279 tempitem.wpn9 = 0;
8432 279 tempitem.wpn10 = 0;
8433 279 break;
8434 }
8435 case itype_divineescape:
8436 {
8437 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8438 279 tempitem.misc2 = 0;
8439 279 tempitem.misc3 = 0;
8440 279 tempitem.misc4 = 0;
8441 279 tempitem.misc5 = 0;
8442 279 tempitem.misc6 = 0;
8443 279 tempitem.misc7 = 0;
8444 279 tempitem.misc8 = 0;
8445 279 tempitem.misc9 = 0;
8446 279 tempitem.misc10 = 0;
8447 279 tempitem.wpn = 0;
8448 279 tempitem.wpn2 = 0;
8449 279 tempitem.wpn3 = 0;
8450 279 tempitem.wpn4 = 0;
8451 279 tempitem.wpn5 = 0;
8452 279 tempitem.wpn6 = 0;
8453 279 tempitem.wpn7 = 0;
8454 279 tempitem.wpn8 = 0;
8455 279 tempitem.wpn9 = 0;
8456 279 tempitem.wpn10 = 0;
8457 279 break;
8458 }
8459 case itype_divineprotection:
8460 {
8461 279 tempitem.flags &= ~ (item_flag5);
8462 279 tempitem.misc2 = 0;
8463 279 tempitem.misc3 = 0;
8464 279 tempitem.misc4 = 0;
8465 279 tempitem.misc5 = 0;
8466 279 tempitem.misc6 = 0;
8467 279 tempitem.misc7 = 0;
8468 279 tempitem.misc8 = 0;
8469 279 tempitem.misc9 = 0;
8470 279 tempitem.misc10 = 0;
8471 279 break;
8472 }
8473 case itype_bomb:
8474 {
8475 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8476 295 tempitem.misc4 = 0;
8477 295 tempitem.misc5 = 0;
8478 295 tempitem.misc6 = 0;
8479 295 tempitem.misc7 = 0;
8480 295 tempitem.misc8 = 0;
8481 295 tempitem.misc9 = 0;
8482 295 tempitem.misc10 = 0;
8483 295 tempitem.wpn3 = 0;
8484 295 tempitem.wpn4 = 0;
8485 295 tempitem.wpn5 = 0;
8486 295 tempitem.wpn6 = 0;
8487 295 tempitem.wpn7 = 0;
8488 295 tempitem.wpn8 = 0;
8489 295 tempitem.wpn9 = 0;
8490 295 tempitem.wpn10 = 0;
8491 295 break;
8492 }
8493 case itype_sbomb:
8494 {
8495 281 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8496 281 tempitem.misc4 = 0;
8497 281 tempitem.misc5 = 0;
8498 281 tempitem.misc6 = 0;
8499 281 tempitem.misc7 = 0;
8500 281 tempitem.misc8 = 0;
8501 281 tempitem.misc9 = 0;
8502 281 tempitem.misc10 = 0;
8503 281 tempitem.wpn3 = 0;
8504 281 tempitem.wpn4 = 0;
8505 281 tempitem.wpn5 = 0;
8506 281 tempitem.wpn6 = 0;
8507 281 tempitem.wpn7 = 0;
8508 281 tempitem.wpn8 = 0;
8509 281 tempitem.wpn9 = 0;
8510 281 tempitem.wpn10 = 0;
8511 281 break;
8512 }
8513 case itype_clock:
8514 {
8515 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8516 282 tempitem.misc2 = 0;
8517 282 tempitem.misc3 = 0;
8518 282 tempitem.misc4 = 0;
8519 282 tempitem.misc5 = 0;
8520 282 tempitem.misc6 = 0;
8521 282 tempitem.misc7 = 0;
8522 282 tempitem.misc8 = 0;
8523 282 tempitem.misc9 = 0;
8524 282 tempitem.misc10 = 0;
8525 282 tempitem.wpn = 0;
8526 282 tempitem.wpn2 = 0;
8527 282 tempitem.wpn3 = 0;
8528 282 tempitem.wpn4 = 0;
8529 282 tempitem.wpn5 = 0;
8530 282 tempitem.wpn6 = 0;
8531 282 tempitem.wpn7 = 0;
8532 282 tempitem.wpn8 = 0;
8533 282 tempitem.wpn9 = 0;
8534 282 tempitem.wpn10 = 0;
8535 282 break;
8536 }
8537 case itype_key:
8538 {
8539 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8540 279 tempitem.misc1 = 0;
8541 279 tempitem.misc2 = 0;
8542 279 tempitem.misc3 = 0;
8543 279 tempitem.misc4 = 0;
8544 279 tempitem.misc5 = 0;
8545 279 tempitem.misc6 = 0;
8546 279 tempitem.misc7 = 0;
8547 279 tempitem.misc8 = 0;
8548 279 tempitem.misc9 = 0;
8549 279 tempitem.misc10 = 0;
8550 279 tempitem.wpn = 0;
8551 279 tempitem.wpn2 = 0;
8552 279 tempitem.wpn3 = 0;
8553 279 tempitem.wpn4 = 0;
8554 279 tempitem.wpn5 = 0;
8555 279 tempitem.wpn6 = 0;
8556 279 tempitem.wpn7 = 0;
8557 279 tempitem.wpn8 = 0;
8558 279 tempitem.wpn9 = 0;
8559 279 tempitem.wpn10 = 0;
8560 279 break;
8561 }
8562 case itype_magiccontainer:
8563 {
8564 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8565 284 tempitem.misc1 = 0;
8566 284 tempitem.misc2 = 0;
8567 284 tempitem.misc3 = 0;
8568 284 tempitem.misc4 = 0;
8569 284 tempitem.misc5 = 0;
8570 284 tempitem.misc6 = 0;
8571 284 tempitem.misc7 = 0;
8572 284 tempitem.misc8 = 0;
8573 284 tempitem.misc9 = 0;
8574 284 tempitem.misc10 = 0;
8575 284 tempitem.wpn = 0;
8576 284 tempitem.wpn2 = 0;
8577 284 tempitem.wpn3 = 0;
8578 284 tempitem.wpn4 = 0;
8579 284 tempitem.wpn5 = 0;
8580 284 tempitem.wpn6 = 0;
8581 284 tempitem.wpn7 = 0;
8582 284 tempitem.wpn8 = 0;
8583 284 tempitem.wpn9 = 0;
8584 284 tempitem.wpn10 = 0;
8585 284 break;
8586 }
8587 case itype_triforcepiece:
8588 {
8589 558 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8590 558 tempitem.misc3 = 0;
8591 558 tempitem.misc4 = 0;
8592 558 tempitem.misc5 = 0;
8593 558 tempitem.misc6 = 0;
8594 558 tempitem.misc7 = 0;
8595 558 tempitem.misc8 = 0;
8596 558 tempitem.misc9 = 0;
8597 558 tempitem.misc10 = 0;
8598 558 tempitem.wpn = 0;
8599 558 tempitem.wpn2 = 0;
8600 558 tempitem.wpn3 = 0;
8601 558 tempitem.wpn4 = 0;
8602 558 tempitem.wpn5 = 0;
8603 558 tempitem.wpn6 = 0;
8604 558 tempitem.wpn7 = 0;
8605 558 tempitem.wpn8 = 0;
8606 558 tempitem.wpn9 = 0;
8607 558 tempitem.wpn10 = 0;
8608 558 break;
8609 }
8610 case itype_map: case itype_compass: case itype_bosskey:
8611 {
8612 842 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8613 842 tempitem.misc1 = 0;
8614 842 tempitem.misc2 = 0;
8615 842 tempitem.misc3 = 0;
8616 842 tempitem.misc4 = 0;
8617 842 tempitem.misc5 = 0;
8618 842 tempitem.misc6 = 0;
8619 842 tempitem.misc7 = 0;
8620 842 tempitem.misc8 = 0;
8621 842 tempitem.misc9 = 0;
8622 842 tempitem.misc10 = 0;
8623 842 tempitem.wpn = 0;
8624 842 tempitem.wpn2 = 0;
8625 842 tempitem.wpn3 = 0;
8626 842 tempitem.wpn4 = 0;
8627 842 tempitem.wpn5 = 0;
8628 842 tempitem.wpn6 = 0;
8629 842 tempitem.wpn7 = 0;
8630 842 tempitem.wpn8 = 0;
8631 842 tempitem.wpn9 = 0;
8632 842 tempitem.wpn10 = 0;
8633 842 break;
8634 }
8635 case itype_quiver:
8636 {
8637 1116 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8638 1116 tempitem.misc3 = 0;
8639 1116 tempitem.misc4 = 0;
8640 1116 tempitem.misc5 = 0;
8641 1116 tempitem.misc6 = 0;
8642 1116 tempitem.misc7 = 0;
8643 1116 tempitem.misc8 = 0;
8644 1116 tempitem.misc9 = 0;
8645 1116 tempitem.misc10 = 0;
8646 1116 tempitem.wpn = 0;
8647 1116 tempitem.wpn2 = 0;
8648 1116 tempitem.wpn3 = 0;
8649 1116 tempitem.wpn4 = 0;
8650 1116 tempitem.wpn5 = 0;
8651 1116 tempitem.wpn6 = 0;
8652 1116 tempitem.wpn7 = 0;
8653 1116 tempitem.wpn8 = 0;
8654 1116 tempitem.wpn9 = 0;
8655 1116 tempitem.wpn10 = 0;
8656 1116 break;
8657 }
8658 case itype_lkey:
8659 {
8660 780 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8661 780 tempitem.misc1 = 0;
8662 780 tempitem.misc2 = 0;
8663 780 tempitem.misc3 = 0;
8664 780 tempitem.misc4 = 0;
8665 780 tempitem.misc5 = 0;
8666 780 tempitem.misc6 = 0;
8667 780 tempitem.misc7 = 0;
8668 780 tempitem.misc8 = 0;
8669 780 tempitem.misc9 = 0;
8670 780 tempitem.misc10 = 0;
8671 780 tempitem.wpn = 0;
8672 780 tempitem.wpn2 = 0;
8673 780 tempitem.wpn3 = 0;
8674 780 tempitem.wpn4 = 0;
8675 780 tempitem.wpn5 = 0;
8676 780 tempitem.wpn6 = 0;
8677 780 tempitem.wpn7 = 0;
8678 780 tempitem.wpn8 = 0;
8679 780 tempitem.wpn9 = 0;
8680 780 tempitem.wpn10 = 0;
8681 780 break;
8682 }
8683 case itype_cbyrna:
8684 {
8685 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8686 279 tempitem.misc4 = 0;
8687 279 tempitem.misc5 = 0;
8688 279 tempitem.misc6 = 0;
8689 279 tempitem.misc7 = 0;
8690 279 tempitem.misc8 = 0;
8691 279 tempitem.misc9 = 0;
8692 279 tempitem.misc10 = 0;
8693 279 tempitem.wpn6 = 0;
8694 279 tempitem.wpn7 = 0;
8695 279 tempitem.wpn8 = 0;
8696 279 tempitem.wpn9 = 0;
8697 279 tempitem.wpn10 = 0;
8698 279 break;
8699 }
8700 case itype_rupee: case itype_arrowammo:
8701 {
8702 3261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8703 3261 tempitem.misc1 = 0;
8704 3261 tempitem.misc2 = 0;
8705 3261 tempitem.misc3 = 0;
8706 3261 tempitem.misc4 = 0;
8707 3261 tempitem.misc5 = 0;
8708 3261 tempitem.misc6 = 0;
8709 3261 tempitem.misc7 = 0;
8710 3261 tempitem.misc8 = 0;
8711 3261 tempitem.misc9 = 0;
8712 3261 tempitem.misc10 = 0;
8713 3261 tempitem.wpn = 0;
8714 3261 tempitem.wpn2 = 0;
8715 3261 tempitem.wpn3 = 0;
8716 3261 tempitem.wpn4 = 0;
8717 3261 tempitem.wpn5 = 0;
8718 3261 tempitem.wpn6 = 0;
8719 3261 tempitem.wpn7 = 0;
8720 3261 tempitem.wpn8 = 0;
8721 3261 tempitem.wpn9 = 0;
8722 3261 tempitem.wpn10 = 0;
8723 3261 break;
8724 }
8725 case itype_fairy:
8726 {
8727 545 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8728 545 tempitem.misc4 = 0;
8729 545 tempitem.misc5 = 0;
8730 545 tempitem.misc6 = 0;
8731 545 tempitem.misc7 = 0;
8732 545 tempitem.misc8 = 0;
8733 545 tempitem.misc9 = 0;
8734 545 tempitem.misc10 = 0;
8735 545 tempitem.wpn = 0;
8736 545 tempitem.wpn2 = 0;
8737 545 tempitem.wpn3 = 0;
8738 545 tempitem.wpn4 = 0;
8739 545 tempitem.wpn5 = 0;
8740 545 tempitem.wpn6 = 0;
8741 545 tempitem.wpn7 = 0;
8742 545 tempitem.wpn8 = 0;
8743 545 tempitem.wpn9 = 0;
8744 545 tempitem.wpn10 = 0;
8745 545 break;
8746 }
8747 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8748 {
8749 2872 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8750 2872 tempitem.misc1 = 0;
8751 2872 tempitem.misc2 = 0;
8752 2872 tempitem.misc3 = 0;
8753 2872 tempitem.misc4 = 0;
8754 2872 tempitem.misc5 = 0;
8755 2872 tempitem.misc6 = 0;
8756 2872 tempitem.misc7 = 0;
8757 2872 tempitem.misc8 = 0;
8758 2872 tempitem.misc9 = 0;
8759 2872 tempitem.misc10 = 0;
8760 2872 tempitem.wpn = 0;
8761 2872 tempitem.wpn2 = 0;
8762 2872 tempitem.wpn3 = 0;
8763 2872 tempitem.wpn4 = 0;
8764 2872 tempitem.wpn5 = 0;
8765 2872 tempitem.wpn6 = 0;
8766 2872 tempitem.wpn7 = 0;
8767 2872 tempitem.wpn8 = 0;
8768 2872 tempitem.wpn9 = 0;
8769 2872 tempitem.wpn10 = 0;
8770 2872 break;
8771 }
8772 case itype_bombbag:
8773 {
8774 1116 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8775 1116 tempitem.misc3 = 0;
8776 1116 tempitem.misc4 = 0;
8777 1116 tempitem.misc5 = 0;
8778 1116 tempitem.misc6 = 0;
8779 1116 tempitem.misc7 = 0;
8780 1116 tempitem.misc8 = 0;
8781 1116 tempitem.misc9 = 0;
8782 1116 tempitem.misc10 = 0;
8783 1116 tempitem.wpn = 0;
8784 1116 tempitem.wpn2 = 0;
8785 1116 tempitem.wpn3 = 0;
8786 1116 tempitem.wpn4 = 0;
8787 1116 tempitem.wpn5 = 0;
8788 1116 tempitem.wpn6 = 0;
8789 1116 tempitem.wpn7 = 0;
8790 1116 tempitem.wpn8 = 0;
8791 1116 tempitem.wpn9 = 0;
8792 1116 tempitem.wpn10 = 0;
8793 1116 break;
8794 }
8795 case itype_rocs:
8796 {
8797 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8798 279 tempitem.misc1 = 0;
8799 279 tempitem.misc2 = 0;
8800 279 tempitem.misc3 = 0;
8801 279 tempitem.misc4 = 0;
8802 279 tempitem.misc5 = 0;
8803 279 tempitem.misc6 = 0;
8804 279 tempitem.misc7 = 0;
8805 279 tempitem.misc8 = 0;
8806 279 tempitem.misc9 = 0;
8807 279 tempitem.misc10 = 0;
8808 279 tempitem.wpn = 0;
8809 279 tempitem.wpn2 = 0;
8810 279 tempitem.wpn3 = 0;
8811 279 tempitem.wpn4 = 0;
8812 279 tempitem.wpn5 = 0;
8813 279 tempitem.wpn6 = 0;
8814 279 tempitem.wpn7 = 0;
8815 279 tempitem.wpn8 = 0;
8816 279 tempitem.wpn9 = 0;
8817 279 tempitem.wpn10 = 0;
8818 279 break;
8819 }
8820 case itype_hoverboots:
8821 {
8822 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8823 279 tempitem.misc2 = 0;
8824 279 tempitem.misc3 = 0;
8825 279 tempitem.misc4 = 0;
8826 279 tempitem.misc5 = 0;
8827 279 tempitem.misc6 = 0;
8828 279 tempitem.misc7 = 0;
8829 279 tempitem.misc8 = 0;
8830 279 tempitem.misc9 = 0;
8831 279 tempitem.misc10 = 0;
8832 279 tempitem.wpn2 = 0;
8833 279 tempitem.wpn3 = 0;
8834 279 tempitem.wpn4 = 0;
8835 279 tempitem.wpn5 = 0;
8836 279 tempitem.wpn6 = 0;
8837 279 tempitem.wpn7 = 0;
8838 279 tempitem.wpn8 = 0;
8839 279 tempitem.wpn9 = 0;
8840 279 tempitem.wpn10 = 0;
8841 279 break;
8842 }
8843 case itype_spinscroll:
8844 {
8845 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8846 279 tempitem.misc2 = 0;
8847 279 tempitem.misc3 = 0;
8848 279 tempitem.misc4 = 0;
8849 279 tempitem.misc5 = 0;
8850 279 tempitem.misc6 = 0;
8851 279 tempitem.misc7 = 0;
8852 279 tempitem.misc8 = 0;
8853 279 tempitem.misc9 = 0;
8854 279 tempitem.misc10 = 0;
8855 279 tempitem.wpn = 0;
8856 279 tempitem.wpn2 = 0;
8857 279 tempitem.wpn3 = 0;
8858 279 tempitem.wpn4 = 0;
8859 279 tempitem.wpn5 = 0;
8860 279 tempitem.wpn6 = 0;
8861 279 tempitem.wpn7 = 0;
8862 279 tempitem.wpn8 = 0;
8863 279 tempitem.wpn9 = 0;
8864 279 tempitem.wpn10 = 0;
8865 279 break;
8866 }
8867 case itype_crossscroll:
8868 {
8869 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8870 279 tempitem.misc1 = 0;
8871 279 tempitem.misc2 = 0;
8872 279 tempitem.misc3 = 0;
8873 279 tempitem.misc4 = 0;
8874 279 tempitem.misc5 = 0;
8875 279 tempitem.misc6 = 0;
8876 279 tempitem.misc7 = 0;
8877 279 tempitem.misc8 = 0;
8878 279 tempitem.misc9 = 0;
8879 279 tempitem.misc10 = 0;
8880 279 tempitem.wpn = 0;
8881 279 tempitem.wpn2 = 0;
8882 279 tempitem.wpn3 = 0;
8883 279 tempitem.wpn4 = 0;
8884 279 tempitem.wpn5 = 0;
8885 279 tempitem.wpn6 = 0;
8886 279 tempitem.wpn7 = 0;
8887 279 tempitem.wpn8 = 0;
8888 279 tempitem.wpn9 = 0;
8889 279 tempitem.wpn10 = 0;
8890 279 break;
8891 }
8892 case itype_quakescroll:
8893 {
8894 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8895 279 tempitem.misc3 = 0;
8896 279 tempitem.misc4 = 0;
8897 279 tempitem.misc5 = 0;
8898 279 tempitem.misc6 = 0;
8899 279 tempitem.misc7 = 0;
8900 279 tempitem.misc8 = 0;
8901 279 tempitem.misc9 = 0;
8902 279 tempitem.misc10 = 0;
8903 279 tempitem.wpn = 0;
8904 279 tempitem.wpn2 = 0;
8905 279 tempitem.wpn3 = 0;
8906 279 tempitem.wpn4 = 0;
8907 279 tempitem.wpn5 = 0;
8908 279 tempitem.wpn6 = 0;
8909 279 tempitem.wpn7 = 0;
8910 279 tempitem.wpn8 = 0;
8911 279 tempitem.wpn9 = 0;
8912 279 tempitem.wpn10 = 0;
8913 279 break;
8914 }
8915 case itype_whispring:
8916 {
8917 561 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8918 561 tempitem.misc2 = 0;
8919 561 tempitem.misc3 = 0;
8920 561 tempitem.misc4 = 0;
8921 561 tempitem.misc5 = 0;
8922 561 tempitem.misc6 = 0;
8923 561 tempitem.misc7 = 0;
8924 561 tempitem.misc8 = 0;
8925 561 tempitem.misc9 = 0;
8926 561 tempitem.misc10 = 0;
8927 561 tempitem.wpn = 0;
8928 561 tempitem.wpn2 = 0;
8929 561 tempitem.wpn3 = 0;
8930 561 tempitem.wpn4 = 0;
8931 561 tempitem.wpn5 = 0;
8932 561 tempitem.wpn6 = 0;
8933 561 tempitem.wpn7 = 0;
8934 561 tempitem.wpn8 = 0;
8935 561 tempitem.wpn9 = 0;
8936 561 tempitem.wpn10 = 0;
8937 561 break;
8938 }
8939 case itype_chargering:
8940 {
8941 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8942 558 tempitem.misc3 = 0;
8943 558 tempitem.misc4 = 0;
8944 558 tempitem.misc5 = 0;
8945 558 tempitem.misc6 = 0;
8946 558 tempitem.misc7 = 0;
8947 558 tempitem.misc8 = 0;
8948 558 tempitem.misc9 = 0;
8949 558 tempitem.misc10 = 0;
8950 558 tempitem.wpn = 0;
8951 558 tempitem.wpn2 = 0;
8952 558 tempitem.wpn3 = 0;
8953 558 tempitem.wpn4 = 0;
8954 558 tempitem.wpn5 = 0;
8955 558 tempitem.wpn6 = 0;
8956 558 tempitem.wpn7 = 0;
8957 558 tempitem.wpn8 = 0;
8958 558 tempitem.wpn9 = 0;
8959 558 tempitem.wpn10 = 0;
8960 558 break;
8961 }
8962 case itype_perilscroll:
8963 {
8964 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8965 279 tempitem.misc2 = 0;
8966 279 tempitem.misc3 = 0;
8967 279 tempitem.misc4 = 0;
8968 279 tempitem.misc5 = 0;
8969 279 tempitem.misc6 = 0;
8970 279 tempitem.misc7 = 0;
8971 279 tempitem.misc8 = 0;
8972 279 tempitem.misc9 = 0;
8973 279 tempitem.misc10 = 0;
8974 279 tempitem.wpn = 0;
8975 279 tempitem.wpn2 = 0;
8976 279 tempitem.wpn3 = 0;
8977 279 tempitem.wpn4 = 0;
8978 279 tempitem.wpn5 = 0;
8979 279 tempitem.wpn6 = 0;
8980 279 tempitem.wpn7 = 0;
8981 279 tempitem.wpn8 = 0;
8982 279 tempitem.wpn9 = 0;
8983 279 tempitem.wpn10 = 0;
8984 279 break;
8985 }
8986 case itype_wealthmedal:
8987 {
8988 840 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8989 840 tempitem.misc2 = 0;
8990 840 tempitem.misc3 = 0;
8991 840 tempitem.misc4 = 0;
8992 840 tempitem.misc5 = 0;
8993 840 tempitem.misc6 = 0;
8994 840 tempitem.misc7 = 0;
8995 840 tempitem.misc8 = 0;
8996 840 tempitem.misc9 = 0;
8997 840 tempitem.misc10 = 0;
8998 840 tempitem.wpn = 0;
8999 840 tempitem.wpn2 = 0;
9000 840 tempitem.wpn3 = 0;
9001 840 tempitem.wpn4 = 0;
9002 840 tempitem.wpn5 = 0;
9003 840 tempitem.wpn6 = 0;
9004 840 tempitem.wpn7 = 0;
9005 840 tempitem.wpn8 = 0;
9006 840 tempitem.wpn9 = 0;
9007 840 tempitem.wpn10 = 0;
9008 840 break;
9009 }
9010 case itype_heartring:
9011 {
9012 843 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9013 843 tempitem.misc3 = 0;
9014 843 tempitem.misc4 = 0;
9015 843 tempitem.misc5 = 0;
9016 843 tempitem.misc6 = 0;
9017 843 tempitem.misc7 = 0;
9018 843 tempitem.misc8 = 0;
9019 843 tempitem.misc9 = 0;
9020 843 tempitem.misc10 = 0;
9021 843 tempitem.wpn = 0;
9022 843 tempitem.wpn2 = 0;
9023 843 tempitem.wpn3 = 0;
9024 843 tempitem.wpn4 = 0;
9025 843 tempitem.wpn5 = 0;
9026 843 tempitem.wpn6 = 0;
9027 843 tempitem.wpn7 = 0;
9028 843 tempitem.wpn8 = 0;
9029 843 tempitem.wpn9 = 0;
9030 843 tempitem.wpn10 = 0;
9031 843 break;
9032 }
9033 case itype_magicring:
9034 {
9035 1128 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9036 1128 tempitem.misc3 = 0;
9037 1128 tempitem.misc4 = 0;
9038 1128 tempitem.misc5 = 0;
9039 1128 tempitem.misc6 = 0;
9040 1128 tempitem.misc7 = 0;
9041 1128 tempitem.misc8 = 0;
9042 1128 tempitem.misc9 = 0;
9043 1128 tempitem.misc10 = 0;
9044 1128 tempitem.wpn = 0;
9045 1128 tempitem.wpn2 = 0;
9046 1128 tempitem.wpn3 = 0;
9047 1128 tempitem.wpn4 = 0;
9048 1128 tempitem.wpn5 = 0;
9049 1128 tempitem.wpn6 = 0;
9050 1128 tempitem.wpn7 = 0;
9051 1128 tempitem.wpn8 = 0;
9052 1128 tempitem.wpn9 = 0;
9053 1128 tempitem.wpn10 = 0;
9054 1128 break;
9055 }
9056 case itype_spinscroll2:
9057 {
9058 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9059 279 tempitem.misc2 = 0;
9060 279 tempitem.misc3 = 0;
9061 279 tempitem.misc4 = 0;
9062 279 tempitem.misc5 = 0;
9063 279 tempitem.misc6 = 0;
9064 279 tempitem.misc7 = 0;
9065 279 tempitem.misc8 = 0;
9066 279 tempitem.misc9 = 0;
9067 279 tempitem.misc10 = 0;
9068 279 tempitem.wpn = 0;
9069 279 tempitem.wpn2 = 0;
9070 279 tempitem.wpn3 = 0;
9071 279 tempitem.wpn4 = 0;
9072 279 tempitem.wpn5 = 0;
9073 279 tempitem.wpn6 = 0;
9074 279 tempitem.wpn7 = 0;
9075 279 tempitem.wpn8 = 0;
9076 279 tempitem.wpn9 = 0;
9077 279 tempitem.wpn10 = 0;
9078 279 break;
9079 }
9080 case itype_quakescroll2:
9081 {
9082 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9083 279 tempitem.misc3 = 0;
9084 279 tempitem.misc4 = 0;
9085 279 tempitem.misc5 = 0;
9086 279 tempitem.misc6 = 0;
9087 279 tempitem.misc7 = 0;
9088 279 tempitem.misc8 = 0;
9089 279 tempitem.misc9 = 0;
9090 279 tempitem.misc10 = 0;
9091 279 tempitem.wpn = 0;
9092 279 tempitem.wpn2 = 0;
9093 279 tempitem.wpn3 = 0;
9094 279 tempitem.wpn4 = 0;
9095 279 tempitem.wpn5 = 0;
9096 279 tempitem.wpn6 = 0;
9097 279 tempitem.wpn7 = 0;
9098 279 tempitem.wpn8 = 0;
9099 279 tempitem.wpn9 = 0;
9100 279 tempitem.wpn10 = 0;
9101 279 break;
9102 }
9103 case itype_agony:
9104 {
9105 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9106 279 tempitem.misc2 = 0;
9107 279 tempitem.misc3 = 0;
9108 279 tempitem.misc4 = 0;
9109 279 tempitem.misc5 = 0;
9110 279 tempitem.misc6 = 0;
9111 279 tempitem.misc7 = 0;
9112 279 tempitem.misc8 = 0;
9113 279 tempitem.misc9 = 0;
9114 279 tempitem.misc10 = 0;
9115 279 tempitem.wpn = 0;
9116 279 tempitem.wpn2 = 0;
9117 279 tempitem.wpn3 = 0;
9118 279 tempitem.wpn4 = 0;
9119 279 tempitem.wpn5 = 0;
9120 279 tempitem.wpn6 = 0;
9121 279 tempitem.wpn7 = 0;
9122 279 tempitem.wpn8 = 0;
9123 279 tempitem.wpn9 = 0;
9124 279 tempitem.wpn10 = 0;
9125 279 break;
9126 }
9127 case itype_stompboots:
9128 {
9129 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9130 279 tempitem.misc1 = 0;
9131 279 tempitem.misc2 = 0;
9132 279 tempitem.misc3 = 0;
9133 279 tempitem.misc4 = 0;
9134 279 tempitem.misc5 = 0;
9135 279 tempitem.misc6 = 0;
9136 279 tempitem.misc7 = 0;
9137 279 tempitem.misc8 = 0;
9138 279 tempitem.misc9 = 0;
9139 279 tempitem.misc10 = 0;
9140 279 tempitem.wpn = 0;
9141 279 tempitem.wpn2 = 0;
9142 279 tempitem.wpn3 = 0;
9143 279 tempitem.wpn4 = 0;
9144 279 tempitem.wpn5 = 0;
9145 279 tempitem.wpn6 = 0;
9146 279 tempitem.wpn7 = 0;
9147 279 tempitem.wpn8 = 0;
9148 279 tempitem.wpn9 = 0;
9149 279 tempitem.wpn10 = 0;
9150 279 break;
9151 }
9152 case itype_whimsicalring:
9153 {
9154 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9155 279 tempitem.misc2 = 0;
9156 279 tempitem.misc3 = 0;
9157 279 tempitem.misc4 = 0;
9158 279 tempitem.misc5 = 0;
9159 279 tempitem.misc6 = 0;
9160 279 tempitem.misc7 = 0;
9161 279 tempitem.misc8 = 0;
9162 279 tempitem.misc9 = 0;
9163 279 tempitem.misc10 = 0;
9164 279 tempitem.wpn = 0;
9165 279 tempitem.wpn2 = 0;
9166 279 tempitem.wpn3 = 0;
9167 279 tempitem.wpn4 = 0;
9168 279 tempitem.wpn5 = 0;
9169 279 tempitem.wpn6 = 0;
9170 279 tempitem.wpn7 = 0;
9171 279 tempitem.wpn8 = 0;
9172 279 tempitem.wpn9 = 0;
9173 279 tempitem.wpn10 = 0;
9174 279 break;
9175 }
9176 case itype_perilring:
9177 {
9178 306 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9179 306 tempitem.misc2 = 0;
9180 306 tempitem.misc3 = 0;
9181 306 tempitem.misc4 = 0;
9182 306 tempitem.misc5 = 0;
9183 306 tempitem.misc6 = 0;
9184 306 tempitem.misc7 = 0;
9185 306 tempitem.misc8 = 0;
9186 306 tempitem.misc9 = 0;
9187 306 tempitem.misc10 = 0;
9188 306 tempitem.wpn = 0;
9189 306 tempitem.wpn2 = 0;
9190 306 tempitem.wpn3 = 0;
9191 306 tempitem.wpn4 = 0;
9192 306 tempitem.wpn5 = 0;
9193 306 tempitem.wpn6 = 0;
9194 306 tempitem.wpn7 = 0;
9195 306 tempitem.wpn8 = 0;
9196 306 tempitem.wpn9 = 0;
9197 306 tempitem.wpn10 = 0;
9198 306 break;
9199 }
9200 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9201 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9202 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9203 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9204 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9205 {
9206 10652 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9207 10652 tempitem.misc1 = 0;
9208 10652 tempitem.misc2 = 0;
9209 10652 tempitem.misc3 = 0;
9210 10652 tempitem.misc4 = 0;
9211 10652 tempitem.misc5 = 0;
9212 10652 tempitem.misc6 = 0;
9213 10652 tempitem.misc7 = 0;
9214 10652 tempitem.misc8 = 0;
9215 10652 tempitem.misc9 = 0;
9216 10652 tempitem.misc10 = 0;
9217 10652 tempitem.wpn = 0;
9218 10652 tempitem.wpn2 = 0;
9219 10652 tempitem.wpn3 = 0;
9220 10652 tempitem.wpn4 = 0;
9221 10652 tempitem.wpn5 = 0;
9222 10652 tempitem.wpn6 = 0;
9223 10652 tempitem.wpn7 = 0;
9224 10652 tempitem.wpn8 = 0;
9225 10652 tempitem.wpn9 = 0;
9226 10652 tempitem.wpn10 = 0;
9227 10652 break;
9228 }
9229 }
9230 72192 }
9231 //Port quest rules to items
9232
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version <= 31)
9233 {
9234
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 71897 times.
72192 if(tempitem.type == itype_bomb)
9235 {
9236
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 139 times.
295 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9237 139 else tempitem.flags &= ~ item_flag2;
9238 295 }
9239
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 71616 times.
71897 else if(tempitem.type == itype_sbomb)
9240 {
9241
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 123 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9242 123 else tempitem.flags &= ~ item_flag2;
9243 281 }
9244
9245
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 70772 times.
71616 else if(tempitem.type == itype_brang)
9246 {
9247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9248 844 else tempitem.flags &= ~ item_flag4;
9249 844 }
9250
2/2
✓ Branch 0 taken 70475 times.
✓ Branch 1 taken 297 times.
70772 else if(tempitem.type == itype_wand)
9251 {
9252
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9253 279 else tempitem.flags &= ~ item_flag3;
9254 297 }
9255 72192 }
9256
9257 //Port quest rules to items
9258
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version <= 37)
9259 {
9260
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71910 times.
72192 if(tempitem.type == itype_flippers)
9261 {
9262
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 203 times.
282 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9263 203 else tempitem.flags &= ~ item_flag1;
9264 282 }
9265
2/2
✓ Branch 0 taken 54363 times.
✓ Branch 1 taken 17547 times.
71910 else if(tempitem.type == itype_sword)
9266 {
9267
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 17109 times.
17547 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9268 17109 else tempitem.flags &= ~ item_flag5;
9269 17547 }
9270
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 54066 times.
54363 else if(tempitem.type == itype_wand)
9271 {
9272
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 288 times.
297 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9273 288 else tempitem.flags &= ~ item_flag5;
9274 297 }
9275
4/4
✓ Branch 0 taken 53771 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 600 times.
✓ Branch 3 taken 53171 times.
54066 else if(tempitem.type == itype_book || tempitem.type == itype_candle)
9276 {
9277 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9278
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 520 times.
895 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9279 520 else tempitem.flags &= ~ item_flag3;
9280 895 }
9281 72192 }
9282
9283
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 38)
9284 {
9285
4/4
✓ Branch 0 taken 71348 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 70788 times.
72192 if(tempitem.type == itype_brang || tempitem.type == itype_hookshot)
9286 {
9287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9288 1404 else tempitem.flags &= ~item_flag4;
9289
9290
2/2
✓ Branch 0 taken 673 times.
✓ Branch 1 taken 731 times.
1404 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9291 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9292 1404 }
9293
2/2
✓ Branch 0 taken 69957 times.
✓ Branch 1 taken 831 times.
70788 else if(tempitem.type == itype_arrow)
9294 {
9295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9296 831 else tempitem.flags &= ~item_flag4;
9297
9298
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 435 times.
831 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9299 435 else tempitem.flags |= item_flag2;
9300 831 }
9301 72192 }
9302
9303
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 39)
9304 {
9305
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 71618 times.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 71018 times.
72192 if(tempitem.type == itype_divinefire || tempitem.type == itype_book || tempitem.type == itype_candle)
9306 {
9307
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1158 times.
1174 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9308 1158 else tempitem.flags &= ~item_flag5;
9309 1174 }
9310
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 70404 times.
71018 else if(tempitem.type == itype_potion)
9311 {
9312
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 452 times.
614 if(get_qr(qr_NONBUBBLEMEDICINE))
9313 {
9314 162 tempitem.flags &= ~(item_flag3|item_flag4);
9315 162 }
9316 else
9317 {
9318 452 tempitem.flags |= item_flag3;
9319
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 333 times.
452 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9320 333 else tempitem.flags &= ~item_flag4;
9321 }
9322 614 }
9323
2/2
✓ Branch 0 taken 69846 times.
✓ Branch 1 taken 558 times.
70404 else if(tempitem.type == itype_triforcepiece)
9324 {
9325
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 474 times.
558 if(get_qr(qr_NONBUBBLETRIFORCE))
9326 {
9327 84 tempitem.flags |= item_flag3;
9328
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9329 28 else tempitem.flags &= ~item_flag4;
9330 84 }
9331 else
9332 {
9333 474 tempitem.flags &= ~(item_flag3|item_flag4);
9334 }
9335 558 }
9336 72192 }
9337
9338
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 40)
9339 {
9340
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 306 times.
✓ Branch 3 taken 70969 times.
72192 if(tempitem.type == itype_ring || tempitem.type == itype_perilring)
9341 {
9342
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 934 times.
1223 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9343 934 else tempitem.flags &= ~item_flag1;
9344 1223 }
9345
8/8
✓ Branch 0 taken 70369 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 52822 times.
✓ Branch 3 taken 17547 times.
✓ Branch 4 taken 52525 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 279 times.
✓ Branch 7 taken 52246 times.
70969 else if(tempitem.type == itype_candle || tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_cbyrna)
9346 {
9347
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18615 times.
18723 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9348 18615 else tempitem.flags &= ~item_flag8;
9349 18723 }
9350
6/6
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
✓ Branch 2 taken 54348 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 54066 times.
72192 if(tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_hammer)
9351 {
9352
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 18048 times.
18126 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9353 18048 else tempitem.flags &= ~item_flag7;
9354 18126 }
9355
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 279 times.
54066 else if(tempitem.type == itype_cbyrna)
9356 {
9357 279 tempitem.flags |= item_flag7;
9358 279 }
9359 72192 }
9360
9361
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 41 )
9362 {
9363
2/2
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
72192 if(tempitem.type == itype_sword)
9364 {
9365
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 17311 times.
17547 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9366 17311 else tempitem.flags &= ~item_flag9;
9367
9368
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17119 times.
17547 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9369 17119 else tempitem.flags &= ~item_flag10;
9370 17547 }
9371 72192 }
9372
9373
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 42 )
9374 {
9375
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 71895 times.
72192 if(tempitem.type == itype_wand)
9376 {
9377
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9378 279 else tempitem.flags &= ~item_flag3;
9379
9380 297 tempitem.flags &= ~item_flag6;
9381 297 }
9382
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71613 times.
71895 else if(tempitem.type == itype_hammer)
9383 {
9384 282 tempitem.flags &= ~item_flag3;
9385 282 }
9386
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 71334 times.
71613 else if(tempitem.type == itype_cbyrna)
9387 {
9388 279 tempitem.flags |= item_flag3;
9389
9390 279 tempitem.flags &= ~item_flag6;
9391 279 }
9392
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 17547 times.
71334 else if(tempitem.type == itype_sword)
9393 {
9394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17547 times.
17547 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9395 17547 else tempitem.flags &= ~item_flag6;
9396 17547 }
9397 72192 }
9398
9399
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 43 )
9400 {
9401
2/2
✓ Branch 0 taken 71865 times.
✓ Branch 1 taken 327 times.
72192 if(tempitem.type == itype_whistle)
9402 {
9403
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 317 times.
327 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9404 317 else tempitem.flags &= ~item_flag3;
9405 327 }
9406 72192 }
9407
9408
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 45 )
9409 {
9410
2/2
✓ Branch 0 taken 71910 times.
✓ Branch 1 taken 282 times.
72192 if(tempitem.type == itype_flippers)
9411 {
9412 282 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9413 282 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9414 282 }
9415 72192 }
9416
9417
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 46 )
9418 {
9419
2/2
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
72192 if(tempitem.type == itype_raft)
9420 {
9421 279 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9422 279 }
9423 72192 }
9424
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if ( s_version < 34 ) //! set the default counter for older quests.
9425 {
9426
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 72076 times.
72192 if ( (tempitem.flags & item_rupee_magic) )
9427 {
9428 116 tempitem.cost_counter[0] = 1;
9429 116 }
9430 else
9431 {
9432
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 29580 times.
72076 if(get_qr(qr_ENABLEMAGIC))
9433 42496 tempitem.cost_counter[0] = 4;
9434 else
9435 {
9436 29580 tempitem.cost_amount[0] = 0;
9437 29580 tempitem.cost_counter[0] = -1;
9438 }
9439 }
9440 72192 }
9441
9442
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if ( s_version < 35 ) //new Lens of Truth flags
9443 {
9444
2/2
✓ Branch 0 taken 71937 times.
✓ Branch 1 taken 255 times.
72192 if ( tempitem.type == itype_lens )
9445 {
9446
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 10 times.
255 if ( get_qr(qr_RAFTLENS) )
9447 {
9448 10 tempitem.flags |= item_flag4;
9449 10 }
9450
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 166 times.
255 if ( get_qr(qr_LENSHINTS) )
9451 {
9452 166 tempitem.flags |= item_flag1;
9453 166 }
9454
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 13 times.
255 if ( get_qr(qr_LENSSEESENEMIES) )
9455 {
9456 13 tempitem.flags |= item_flag5;
9457 13 }
9458 255 }
9459 72192 }
9460
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9461 {
9462
2/2
✓ Branch 0 taken 577536 times.
✓ Branch 1 taken 72192 times.
649728 for ( int32_t q = 0; q < 8; q++ )
9463 {
9464 577536 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9465 577536 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9466 577536 tempitem.sprite_initiald[q] = 0;
9467 577536 }
9468 72192 tempitem.sprite_script = 0;
9469 72192 }
9470
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9471 {
9472 72192 tempitem.pickupflag = 0;
9473 72192 }
9474
9475
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 51 )
9476 {
9477
2/2
✓ Branch 0 taken 71592 times.
✓ Branch 1 taken 600 times.
72192 if( tempitem.type == itype_candle )
9478 {
9479 600 tempitem.misc4 = 50; //Step speed
9480 600 }
9481 72192 }
9482
9483
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if( s_version < 52 )
9484 {
9485
2/2
✓ Branch 0 taken 71334 times.
✓ Branch 1 taken 858 times.
72192 if( tempitem.type == itype_shield )
9486 858 tempitem.flags |= item_flag1; //'Block Front' flag
9487 72192 }
9488
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 72192 times.
125952 if(s_version < 53)
9489 {
9490
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 70785 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 281 times.
72192 switch(tempitem.type)
9491 {
9492 case itype_arrow:
9493 831 tempitem.cost_counter[1] = crARROWS;
9494 831 tempitem.cost_amount[1] = 1;
9495 831 break;
9496 case itype_bomb:
9497 295 tempitem.cost_counter[1] = crBOMBS;
9498 295 tempitem.cost_amount[1] = 1;
9499 295 break;
9500 case itype_sbomb:
9501 281 tempitem.cost_counter[1] = crSBOMBS;
9502 281 tempitem.cost_amount[1] = 1;
9503 281 break;
9504 default:
9505 70785 tempitem.cost_counter[1] = crNONE;
9506 70785 tempitem.cost_amount[1] = 0;
9507 70785 }
9508 72192 tempitem.magiccosttimer[1] = 0;
9509 72192 }
9510
2/2
✓ Branch 0 taken 50944 times.
✓ Branch 1 taken 75008 times.
125952 if( s_version < 54 )
9511 {
9512
2/2
✓ Branch 0 taken 74713 times.
✓ Branch 1 taken 295 times.
75008 if( tempitem.type == itype_flippers )
9513 295 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9514 75008 }
9515
2/2
✓ Branch 0 taken 50944 times.
✓ Branch 1 taken 75008 times.
125952 if(s_version < 55)
9516 {
9517
3/3
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 73848 times.
75008 switch(tempitem.type)
9518 {
9519 case itype_spinscroll:
9520 case itype_quakescroll:
9521 580 tempitem.usesound2 = WAV_ZN1CHARGE;
9522 580 break;
9523 case itype_spinscroll2:
9524 case itype_quakescroll2:
9525 580 tempitem.usesound2 = WAV_ZN1CHARGE2;
9526 580 break;
9527 }
9528 75008 }
9529
2/2
✓ Branch 0 taken 50944 times.
✓ Branch 1 taken 75008 times.
125952 if(s_version < 56)
9530 {
9531
4/4
✓ Branch 0 taken 73786 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 306 times.
75008 switch(tempitem.type)
9532 {
9533 case itype_divinefire:
9534
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 11 times.
290 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9535
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9536 290 tempitem.flags |= item_flag11; //Divine Fire
9537 290 break;
9538 case itype_candle:
9539
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 314 times.
626 SETFLAG(tempitem.flags, item_flag9, tempitem.level > 1); //Strong Fire
9540 626 tempitem.flags &= ~item_flag10; //Magic Fire
9541 626 tempitem.flags &= ~item_flag11; //Divine Fire
9542 626 break;
9543 case itype_book:
9544 306 tempitem.flags |= item_flag9; //Strong Fire
9545 306 tempitem.flags |= item_flag10; //Magic Fire
9546 306 tempitem.flags &= ~item_flag11; //Divine Fire
9547 306 break;
9548 }
9549 75008 }
9550
2/2
✓ Branch 0 taken 42240 times.
✓ Branch 1 taken 83712 times.
125952 if (s_version < 61)
9551 {
9552
2/2
✓ Branch 0 taken 65334 times.
✓ Branch 1 taken 18378 times.
83712 switch (tempitem.type)
9553 {
9554 case itype_sword:
9555 18378 tempitem.usesound2 = WAV_BEAM;
9556 18378 break;
9557 }
9558 83712 }
9559
9560
9561
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 114964 times.
125952 if(tempitem.level==0) // Always do this
9562 10988 tempitem.level=1;
9563
9564 125952 itemsbuf[i] = tempitem;
9565 125952 }
9566
9567 492 return 0;
9568 493 }
9569
9570 static bool did_init_def_items = false;
9571 251770 void init_def_items()
9572 {
9573
2/2
✓ Branch 0 taken 251390 times.
✓ Branch 1 taken 380 times.
251770 if(did_init_def_items) return;
9574 380 did_init_def_items = true;
9575 380 default_items[3].cost_counter[1] = crBOMBS;
9576 380 default_items[13].cost_counter[1] = crARROWS;
9577 380 default_items[14].cost_counter[1] = crARROWS;
9578 380 default_items[48].cost_counter[1] = crSBOMBS;
9579 380 default_items[57].cost_counter[1] = crARROWS;
9580 251770 }
9581 251770 void reset_itembuf(itemdata *item, int32_t id)
9582 {
9583 251770 init_def_items();
9584
2/2
✓ Branch 0 taken 105881 times.
✓ Branch 1 taken 145889 times.
251770 if(id<iLast)
9585 {
9586 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9587 145889 word tile = item->tile;
9588 145889 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9589 145889 int32_t ltm = item->ltm;
9590
9591 145889 *item = default_items[id];
9592 145889 item->tile = tile;
9593 145889 item->misc_flags = miscs;
9594 145889 item->csets = cset;
9595 145889 item->frames = frames;
9596 145889 item->speed = speed;
9597 145889 item->delay = delay;
9598 145889 item->ltm = ltm;
9599 145889 }
9600 251770 }
9601
9602 103680 void reset_itemname(int32_t id)
9603 {
9604 103680 sprintf(item_string[id],"zz%03d",id);
9605
9606
2/2
✓ Branch 0 taken 45765 times.
✓ Branch 1 taken 57915 times.
103680 if(id < iLast)
9607 57915 strcpy(item_string[id],old_item_string[id]);
9608 103680 }
9609
9610 493 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9611 {
9612
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9613
9614 493 word weapons_to_read=MAXWPNS;
9615 int32_t dummy;
9616 byte padding;
9617 wpndata tempweapon;
9618 493 word s_version=0;
9619
9620
9621
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 6 times.
493 if(Header->zelda_version < 0x186)
9622 {
9623 6 weapons_to_read=64;
9624 6 }
9625
9626
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 6 times.
493 if(Header->zelda_version < 0x185)
9627 {
9628 6 weapons_to_read=32;
9629 6 }
9630
9631
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 469 times.
493 if(Header->zelda_version > 0x192)
9632 {
9633 469 weapons_to_read=0;
9634
9635 //section version info
9636
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&s_version,f))
9637 {
9638 return qe_invalid;
9639 }
9640
9641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (s_version > V_WEAPONS)
9642 return qe_version;
9643
9644 469 FFCore.quest_format[vWeaponSprites] = s_version;
9645
9646
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!read_deprecated_section_cversion(f))
9647 {
9648 return qe_invalid;
9649 }
9650
9651 //section size
9652
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy,f))
9653 {
9654 return qe_invalid;
9655 }
9656
9657 //finally... section data
9658
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&weapons_to_read,f))
9659 {
9660 return qe_invalid;
9661 }
9662
9663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (weapons_to_read > MAXWPNS)
9664 {
9665 return qe_invalid;
9666 }
9667 469 }
9668
9669
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 83 times.
493 if(s_version>2)
9670 {
9671
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i=0; i<weapons_to_read; i++)
9672 {
9673 char tempname[64];
9674
9675
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!pfread(tempname, 64, f))
9676 {
9677 return qe_invalid;
9678 }
9679
9680 104960 weapon_string[i][0] = '\0';
9681 104960 strncat(weapon_string[i], tempname, 64 - 1);
9682 104960 }
9683
9684
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(s_version<4)
9685 {
9686 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9687 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9688 }
9689
9690
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(s_version<5)
9691 {
9692 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9693 }
9694
9695 /*
9696 if (s_version<6)
9697 {
9698 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9699 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9700 }
9701 */
9702 410 }
9703
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9704 {
9705
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9706 20992 reset_weaponname(i);
9707 82 }
9708
9709
2/2
✓ Branch 0 taken 113772 times.
✓ Branch 1 taken 493 times.
114265 for(int32_t i=0; i<weapons_to_read; i++)
9710 {
9711 113772 word oldtile = 0;
9712
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 61292 times.
113772 if (s_version < 8)
9713 {
9714
1/2
✓ Branch 0 taken 61292 times.
✗ Branch 1 not taken.
61292 if (!p_igetw(&oldtile, f))
9715 return qe_invalid;
9716 61292 }
9717
9718
1/2
✓ Branch 0 taken 113772 times.
✗ Branch 1 not taken.
113772 if(!p_getc(&tempweapon.misc,f))
9719 {
9720 return qe_invalid;
9721 }
9722
9723
1/2
✓ Branch 0 taken 113772 times.
✗ Branch 1 not taken.
113772 if(!p_getc(&tempweapon.csets,f))
9724 {
9725 return qe_invalid;
9726 }
9727
9728
1/2
✓ Branch 0 taken 113772 times.
✗ Branch 1 not taken.
113772 if(!p_getc(&tempweapon.frames,f))
9729 {
9730 return qe_invalid;
9731 }
9732
9733
1/2
✓ Branch 0 taken 113772 times.
✗ Branch 1 not taken.
113772 if(!p_getc(&tempweapon.speed,f))
9734 {
9735 return qe_invalid;
9736 }
9737
9738
1/2
✓ Branch 0 taken 113772 times.
✗ Branch 1 not taken.
113772 if(!p_getc(&tempweapon.type,f))
9739 {
9740 return qe_invalid;
9741 }
9742
9743
2/2
✓ Branch 0 taken 60012 times.
✓ Branch 1 taken 53760 times.
113772 if ( s_version >= 7 )
9744 {
9745
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempweapon.script,f))
9746 {
9747 return qe_invalid;
9748 }
9749
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempweapon.tile,f))
9750 {
9751 return qe_invalid;
9752 }
9753 53760 }
9754
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 60012 times.
113772 if ( s_version < 7 )
9755 {
9756 60012 tempweapon.tile = oldtile;
9757 60012 }
9758
9759
2/2
✓ Branch 0 taken 108972 times.
✓ Branch 1 taken 4800 times.
113772 if(Header->zelda_version < 0x193)
9760 {
9761
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9762 {
9763 return qe_invalid;
9764 }
9765 4800 }
9766
9767
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 8812 times.
113772 if(s_version < 6)
9768 {
9769
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9770 {
9771 18 tempweapon.misc |= WF_BEHIND;
9772 18 }
9773 else
9774 8794 tempweapon.misc &= ~WF_BEHIND;
9775 8812 }
9776
9777
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 113516 times.
113772 if (!should_skip)
9778 113516 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9779 113772 }
9780
9781
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 492 times.
493 if (should_skip)
9782 1 return 0;
9783
9784
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
492 if(s_version<2)
9785 {
9786 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9787 82 }
9788
9789
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
492 if(s_version<5)
9790 {
9791 82 wpnsbuf[iwQuarterHearts].tile=1;
9792 82 wpnsbuf[iwQuarterHearts].csets=1;
9793 82 }
9794
9795
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(Header->zelda_version < 0x176)
9796 {
9797 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9798 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9799 itemsbuf[iMisc1].clear();
9800 itemsbuf[iMisc2].clear();
9801 }
9802
9803
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
497 if((Header->zelda_version < 0x192)||
9804
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 469 times.
474 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9805 {
9806 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9807 18 }
9808
9809
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
492 if((Header->zelda_version < 0x210))
9810 {
9811 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9812 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9813 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9814 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9815 23 }
9816
9817 492 return 0;
9818 493 }
9819
9820 223484 static void guy_update_firesfx(guydata& tempguy)
9821 {
9822 223484 tempguy.firesfx = 0;
9823
2/2
✓ Branch 0 taken 6511 times.
✓ Branch 1 taken 216973 times.
223484 if (tempguy.type == eeWIZZ)
9824 {
9825
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✓ Branch 2 taken 3980 times.
✓ Branch 3 taken 838 times.
✓ Branch 4 taken 710 times.
6511 switch (tempguy.attributes[1])
9826 {
9827 case 0: // normal weapon
9828 3980 tempguy.firesfx = WAV_WAND;
9829 3980 break;
9830 case 1: // 8 shots
9831
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 756 times.
838 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9832 else
9833 {
9834
3/8
✓ Branch 0 taken 652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
756 switch (tempguy.weapon)
9835 {
9836 case ewFireTrail:
9837 case ewFlame:
9838 case ewFlame2Trail:
9839 case ewFlame2:
9840 652 tempguy.firesfx = WAV_FIRE;
9841 652 break;
9842 case ewWind:
9843 case ewMagic:
9844 88 tempguy.firesfx = WAV_WAND;
9845 88 break;
9846 case ewIce:
9847 tempguy.firesfx = WAV_ZN1ICE;
9848 break;
9849 case ewRock:
9850 tempguy.firesfx = WAV_ZN1ROCK;
9851 break;
9852 case ewFireball2:
9853 case ewFireball:
9854 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9855 16 break;
9856 case ewBrang:
9857 tempguy.firesfx = WAV_BRANG;
9858 break;
9859 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9860 tempguy.firesfx = WAV_BOMB;
9861 break;
9862 default:
9863 tempguy.firesfx = 0;
9864 break;
9865 }
9866 756 break;
9867 }
9868 case 2: // Summon
9869 1065 tempguy.firesfx = WAV_FIRE;
9870 1065 break;
9871 case 3: // Summon Layer
9872 710 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9873 710 break;
9874 }
9875 6511 }
9876 else
9877 {
9878
6/6
✓ Branch 0 taken 163549 times.
✓ Branch 1 taken 53424 times.
✓ Branch 2 taken 42460 times.
✓ Branch 3 taken 206009 times.
✓ Branch 4 taken 47944 times.
✓ Branch 5 taken 47940 times.
216973 if ((tempguy.type == eeWALK || tempguy.type == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9879 {
9880 95884 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9881 95884 }
9882 else
9883 {
9884
7/8
✓ Branch 0 taken 9747 times.
✓ Branch 1 taken 2387 times.
✓ Branch 2 taken 1820 times.
✓ Branch 3 taken 12983 times.
✓ Branch 4 taken 172765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4011 times.
✓ Branch 7 taken 2296 times.
206009 switch (tempguy.weapon)
9885 {
9886 case ewFireTrail:
9887 case ewFlame:
9888 case ewFlame2Trail:
9889 case ewFlame2:
9890 9747 tempguy.firesfx = WAV_FIRE;
9891 9747 break;
9892 case ewWind:
9893 case ewMagic:
9894 1820 tempguy.firesfx = WAV_WAND;
9895 1820 break;
9896 case ewIce:
9897 tempguy.firesfx = WAV_ZN1ICE;
9898 break;
9899 case ewRock:
9900 4011 tempguy.firesfx = WAV_ZN1ROCK;
9901 4011 break;
9902 case ewFireball2:
9903 case ewFireball:
9904 12983 tempguy.firesfx = WAV_ZN1FIREBALL;
9905 12983 break;
9906 case ewBrang:
9907 2296 tempguy.firesfx = WAV_BRANG;
9908 2296 break;
9909 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9910 2387 tempguy.firesfx = WAV_BOMB;
9911 2387 break;
9912 default:
9913 172765 tempguy.firesfx = 0;
9914 172765 break;
9915 }
9916 }
9917 }
9918 212524 }
9919
9920 212524 static void guy_update_weaponflags(guydata& tempguy)
9921 {
9922 212524 tempguy.weap_data.unblockable = 0;
9923 212524 tempguy.weap_data.moveflags = move_none;
9924
4/4
✓ Branch 0 taken 205908 times.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 3044 times.
✓ Branch 3 taken 202864 times.
212524 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9925 9660 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
9926 212524 tempguy.weap_data.override_flags = 0;
9927 212524 tempguy.weap_data.hxofs = 0;
9928 212524 tempguy.weap_data.hyofs = 0;
9929 212524 tempguy.weap_data.hxsz = 0;
9930 212524 tempguy.weap_data.hysz = 0;
9931 212524 tempguy.weap_data.hzsz = 0;
9932 212524 tempguy.weap_data.xofs = 0;
9933 212524 tempguy.weap_data.yofs = 0;
9934 212524 tempguy.weap_data.tilew = 0;
9935 212524 tempguy.weap_data.tileh = 0;
9936
5/5
✓ Branch 0 taken 2536 times.
✓ Branch 1 taken 170770 times.
✓ Branch 2 taken 18739 times.
✓ Branch 3 taken 12999 times.
✓ Branch 4 taken 7480 times.
212524 switch (tempguy.weapon)
9937 {
9938 case ewFireball: case ewFireball2:
9939 12999 tempguy.weap_data.step = 1.75_zf;
9940 12999 break;
9941 case ewSword: case ewLitBomb: case ewLitSBomb:
9942 case ewRock: case ewMagic: case ewWind:
9943 18739 tempguy.weap_data.step = 3_zf;
9944 18739 break;
9945 case ewArrow:
9946 2536 tempguy.weap_data.step = 2_zf;
9947 2536 break;
9948 case ewFlame: case ewFlame2:
9949 7480 tempguy.weap_data.step = 1_zf;
9950 7480 break;
9951 default:
9952 170770 tempguy.weap_data.step = 0_zf;
9953 170770 break;
9954 }
9955
2/2
✓ Branch 0 taken 1062620 times.
✓ Branch 1 taken 212524 times.
1275144 for (int q = 0; q < WPNSPR_MAX; ++q)
9956 {
9957 1062620 tempguy.weap_data.burnsprs[q] = 0;
9958 1062620 tempguy.weap_data.light_rads[q] = 0;
9959 1062620 }
9960 212524 }
9961
9962 212524 static void guy_update_weaponspecialsfx(guydata& tempguy)
9963 {
9964
3/3
✓ Branch 0 taken 2296 times.
✓ Branch 1 taken 207786 times.
✓ Branch 2 taken 2442 times.
212524 switch (tempguy.weapon)
9965 {
9966 case ewBrang:
9967 2296 tempguy.specialsfx = WAV_BRANG;
9968 2296 break;
9969 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9970 2442 tempguy.specialsfx = WAV_BOMB;
9971 2442 break;
9972 default:
9973 207786 tempguy.specialsfx = 0;
9974 207786 break;
9975 }
9976 212524 }
9977
9978 492 void init_guys(int32_t guyversion)
9979 {
9980
2/2
✓ Branch 0 taken 251904 times.
✓ Branch 1 taken 492 times.
252396 for(int32_t i=0; i<MAXGUYS; i++)
9981 {
9982 251904 guysbuf[i] = default_guys[0];
9983 251904 }
9984
9985
2/2
✓ Branch 0 taken 87084 times.
✓ Branch 1 taken 492 times.
87576 for(int32_t i=0; i<OLDMAXGUYS; i++)
9986 {
9987 87084 guysbuf[i] = default_guys[i];
9988
2/2
✓ Branch 0 taken 86100 times.
✓ Branch 1 taken 984 times.
87084 guysbuf[i].spr_shadow = (guysbuf[i].type==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9989 87084 guysbuf[i].spr_death = iwDeath;
9990 87084 guysbuf[i].spr_spawn = iwSpawn;
9991 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9992
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 72570 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
87084 if(guyversion<=3 && i==ePATRABS)
9993 {
9994 82 guysbuf[i].bosspal=spDIG;
9995 82 guysbuf[i].cset=14;
9996 82 guysbuf[i].attributes[8] = 14;
9997 82 }
9998
9999
2/2
✓ Branch 0 taken 72570 times.
✓ Branch 1 taken 14514 times.
87084 if(guyversion<=3)
10000 {
10001 // Rope/Ghini Flash rules
10002
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
10003 {
10004
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
10005 {
10006 59 guysbuf[i].flags &= ~guy_flashing;
10007 59 }
10008 10443 }
10009
10010
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
10011 {
10012
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
10013 {
10014 72 guysbuf[i].flags &= ~guy_flashing;
10015 72 }
10016 2124 }
10017
10018
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
10019 {
10020
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
10021 {
10022 4 guysbuf[i].flags |= guy_blinking;
10023 4 }
10024
10025
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
10026 {
10027 38 guysbuf[i].flags |= guy_transparent;
10028 38 }
10029 82 }
10030
10031
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
10032 {
10033 164 guysbuf[i].flags |= guy_ignore_kill_all;
10034 164 }
10035 14514 }
10036
10037 // Darknut fix
10038
10/10
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 492 times.
✓ Branch 2 taken 86100 times.
✓ Branch 3 taken 492 times.
✓ Branch 4 taken 85608 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 85116 times.
✓ Branch 7 taken 492 times.
✓ Branch 8 taken 492 times.
✓ Branch 9 taken 84624 times.
87084 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
10039 {
10040
2/2
✓ Branch 0 taken 2050 times.
✓ Branch 1 taken 410 times.
2460 if(get_qr(qr_NEWENEMYTILES))
10041 {
10042 2050 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
10043 2050 guysbuf[i].s_width=guysbuf[i].e_width;
10044 2050 guysbuf[i].s_height=guysbuf[i].e_height;
10045 2050 }
10046 410 else guysbuf[i].s_tile=860;
10047
10048
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2140 times.
2460 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
10049 2140 guysbuf[i].flags &= ~guy_bkshield;
10050 else
10051 320 guysbuf[i].flags |= guy_bkshield;
10052 2460 }
10053
10054
4/4
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 492 times.
✓ Branch 2 taken 87034 times.
✓ Branch 3 taken 50 times.
87084 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
10055 {
10056 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
10057 50 }
10058
10059 87084 guy_update_firesfx(guysbuf[i]);
10060 87084 guy_update_weaponflags(guysbuf[i]);
10061 87084 guy_update_weaponspecialsfx(guysbuf[i]);
10062 87084 }
10063 492 }
10064
10065 20992 void reset_weaponname(int32_t i)
10066 {
10067
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
10068 {
10069 7216 strcpy(weapon_string[i],old_weapon_string[i]);
10070 7216 }
10071 else
10072 13776 sprintf(weapon_string[i],"zz%03d",i);
10073 20992 }
10074
10075 492 void init_item_drop_sets()
10076 {
10077
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
10078 {
10079 // item_drop_sets[i] = default_item_drop_sets[0];
10080 125952 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10081 125952 }
10082
10083
2/2
✓ Branch 0 taken 6396 times.
✓ Branch 1 taken 492 times.
6888 for(int32_t i=0; i<isMAX; i++)
10084 {
10085 6396 item_drop_sets[i] = default_item_drop_sets[i];
10086
10087 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10088
2/2
✓ Branch 0 taken 63960 times.
✓ Branch 1 taken 6396 times.
70356 for(int32_t j=0; j<10; ++j)
10089 {
10090 63960 int32_t it = item_drop_sets[i].item[j];
10091
10092
3/4
✓ Branch 0 taken 44988 times.
✓ Branch 1 taken 18972 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2904 times.
63960 if((itemsbuf[it].type == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10093
2/2
✓ Branch 0 taken 2904 times.
✓ Branch 1 taken 42084 times.
44988 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10094 {
10095 2904 item_drop_sets[i].chance[j+1]=0;
10096 2904 }
10097
4/4
✓ Branch 0 taken 1968 times.
✓ Branch 1 taken 59088 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1824 times.
61056 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10098 {
10099 144 item_drop_sets[i].chance[j+1]=0;
10100 144 }
10101
10102 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10103
2/2
✓ Branch 0 taken 63936 times.
✓ Branch 1 taken 24 times.
63960 if(itemsbuf[it].type == itype_misc)
10104 {
10105 // If a non-gameplay item was selected, then item drop was aborted.
10106 // Reflect this by increasing the 'Nothing' chance accordingly.
10107 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10108 24 item_drop_sets[i].chance[j+1]=0;
10109 24 }
10110 63960 }
10111 6396 }
10112 492 }
10113
10114 492 void init_favorites()
10115 {
10116
2/2
✓ Branch 0 taken 619920 times.
✓ Branch 1 taken 492 times.
620412 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10117 {
10118 619920 favorite_combos[i]=-1;
10119 619920 }
10120 492 }
10121
10122 779 int32_t init_combo_classes()
10123 {
10124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10125
2/2
✓ Branch 0 taken 143336 times.
✓ Branch 1 taken 779 times.
144115 for(int32_t i=0; i<cMAX; i++)
10126 {
10127 143336 combo_class_buf[i] = default_combo_classes[i];
10128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143336 times.
143336 if ( char const* nm = zi->getComboTypeName(i) )
10129 {
10130 143336 size_t len = strlen(nm);
10131
2/2
✓ Branch 0 taken 9173504 times.
✓ Branch 1 taken 143336 times.
9316840 for ( size_t q = 0; q < 64; q++ )
10132 {
10133
2/2
✓ Branch 0 taken 2100963 times.
✓ Branch 1 taken 7072541 times.
9173504 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10134 9173504 }
10135 143336 }
10136 143336 }
10137
10138 779 return 0;
10139 }
10140
10141 305 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10142 {
10143
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 259 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if (should_skip) return 0;
10145
10146
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 assert(v_herosprites < 6);
10147
10148 305 zinit.hero_swim_speed=67; //default
10149 305 setupherotiles(zinit.heroAnimationStyle);
10150 305 setupherodefenses();
10151 305 setupherooffsets();
10152
10153
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 200 times.
305 if(v_herosprites>=0)
10154 {
10155 word tile, tile2;
10156 byte flip, extend, dummy_byte;
10157
10158
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10159 {
10160
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10161 {
10162 return qe_invalid;
10163 }
10164
10165
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10166 {
10167 return qe_invalid;
10168 }
10169
10170
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10171 {
10172 return qe_invalid;
10173 }
10174
10175 800 walkspr[i][spr_tile]=(int32_t)tile;
10176 800 walkspr[i][spr_flip]=(int32_t)flip;
10177 800 walkspr[i][spr_extend]=(int32_t)extend;
10178 800 }
10179
10180
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10181 {
10182
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10183 {
10184 return qe_invalid;
10185 }
10186
10187
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10188 {
10189 return qe_invalid;
10190 }
10191
10192
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10193 {
10194 return qe_invalid;
10195 }
10196
10197 800 stabspr[i][spr_tile]=(int32_t)tile;
10198 800 stabspr[i][spr_flip]=(int32_t)flip;
10199 800 stabspr[i][spr_extend]=(int32_t)extend;
10200 800 }
10201
10202
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10203 {
10204
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10210 {
10211 return qe_invalid;
10212 }
10213
10214
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10215 {
10216 return qe_invalid;
10217 }
10218
10219 800 slashspr[i][spr_tile]=(int32_t)tile;
10220 800 slashspr[i][spr_flip]=(int32_t)flip;
10221 800 slashspr[i][spr_extend]=(int32_t)extend;
10222 800 }
10223
10224
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10225 {
10226
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10227 {
10228 return qe_invalid;
10229 }
10230
10231
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241 800 floatspr[i][spr_tile]=(int32_t)tile;
10242 800 floatspr[i][spr_flip]=(int32_t)flip;
10243 800 floatspr[i][spr_extend]=(int32_t)extend;
10244 800 }
10245
10246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>1)
10247 {
10248
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10249 {
10250
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10251 {
10252 return qe_invalid;
10253 }
10254
10255
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10256 {
10257 return qe_invalid;
10258 }
10259
10260
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10261 {
10262 return qe_invalid;
10263 }
10264
10265 800 swimspr[i][spr_tile]=(int32_t)tile;
10266 800 swimspr[i][spr_flip]=(int32_t)flip;
10267 800 swimspr[i][spr_extend]=(int32_t)extend;
10268 800 }
10269 200 }
10270
10271
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10272 {
10273
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10274 {
10275 return qe_invalid;
10276 }
10277
10278
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10279 {
10280 return qe_invalid;
10281 }
10282
10283
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10284 {
10285 return qe_invalid;
10286 }
10287
10288 800 divespr[i][spr_tile]=(int32_t)tile;
10289 800 divespr[i][spr_flip]=(int32_t)flip;
10290 800 divespr[i][spr_extend]=(int32_t)extend;
10291 800 }
10292
10293
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10294 {
10295
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10296 {
10297 return qe_invalid;
10298 }
10299
10300
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10301 {
10302 return qe_invalid;
10303 }
10304
10305
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10306 {
10307 return qe_invalid;
10308 }
10309
10310 800 poundspr[i][spr_tile]=(int32_t)tile;
10311 800 poundspr[i][spr_flip]=(int32_t)flip;
10312 800 poundspr[i][spr_extend]=(int32_t)extend;
10313 800 }
10314
10315
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&tile,f))
10316 {
10317 return qe_invalid;
10318 }
10319
10320 200 flip=0;
10321
10322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>0)
10323 {
10324
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&flip,f))
10325 {
10326 return qe_invalid;
10327 }
10328 200 }
10329
10330
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&extend,f))
10331 {
10332 return qe_invalid;
10333 }
10334
10335 200 castingspr[spr_tile]=(int32_t)tile;
10336 200 castingspr[spr_flip]=(int32_t)flip;
10337 200 castingspr[spr_extend]=(int32_t)extend;
10338
10339
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(v_herosprites>0)
10340 {
10341 200 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10342
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
600 for(int32_t i=0; i<2; i++)
10343 {
10344
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 400 times.
1200 for(int32_t j=0; j<num_holdsprs; j++)
10345 {
10346
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10347 {
10348 return qe_invalid;
10349 }
10350
10351
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10352 {
10353 return qe_invalid;
10354 }
10355
10356
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10357 {
10358 return qe_invalid;
10359 }
10360
10361 800 holdspr[i][j][spr_tile]=(int32_t)tile;
10362 800 holdspr[i][j][spr_flip]=(int32_t)flip;
10363 800 holdspr[i][j][spr_extend]=(int32_t)extend;
10364 800 }
10365 400 }
10366 200 }
10367 else
10368 {
10369 for(int32_t i=0; i<2; i++)
10370 {
10371 if(!p_igetw(&tile,f))
10372 {
10373 return qe_invalid;
10374 }
10375
10376 if(!p_igetw(&tile2,f))
10377 {
10378 return qe_invalid;
10379 }
10380
10381 if(!p_getc(&extend,f))
10382 {
10383 return qe_invalid;
10384 }
10385
10386 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10387 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10388 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10389 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10390 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10391 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10392 }
10393 }
10394
10395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>2)
10396 {
10397
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10398 {
10399
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10400 {
10401 return qe_invalid;
10402 }
10403
10404
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10405 {
10406 return qe_invalid;
10407 }
10408
10409
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10410 {
10411 return qe_invalid;
10412 }
10413
10414 800 jumpspr[i][spr_tile]=(int32_t)tile;
10415 800 jumpspr[i][spr_flip]=(int32_t)flip;
10416 800 jumpspr[i][spr_extend]=(int32_t)extend;
10417 800 }
10418 200 }
10419
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>3)
10421 {
10422
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10423 {
10424
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10425 {
10426 return qe_invalid;
10427 }
10428
10429
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10430 {
10431 return qe_invalid;
10432 }
10433
10434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_getc(&extend,f))
10435 {
10436 return qe_invalid;
10437 }
10438
10439 800 chargespr[i][spr_tile]=(int32_t)tile;
10440 800 chargespr[i][spr_flip]=(int32_t)flip;
10441 800 chargespr[i][spr_extend]=(int32_t)extend;
10442 800 }
10443 200 }
10444
10445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>4)
10446 {
10447
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&dummy_byte,f))
10448 {
10449 return qe_invalid;
10450 }
10451
10452 200 zinit.hero_swim_speed=(byte)dummy_byte;
10453 200 }
10454
10455 200 memset(frozenspr, 0, sizeof(frozenspr));
10456 200 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10457 200 memset(onfirespr, 0, sizeof(onfirespr));
10458 200 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10459 200 memset(diggingspr, 0, sizeof(diggingspr));
10460 200 memset(usingrodspr, 0, sizeof(usingrodspr));
10461 200 memset(usingcanespr, 0, sizeof(usingcanespr));
10462 200 memset(pushingspr, 0, sizeof(pushingspr));
10463 200 memset(liftingspr, 0, sizeof(liftingspr));
10464 200 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10465 200 memset(stunnedspr, 0, sizeof(stunnedspr));
10466 200 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10467 200 memset(fallingspr, 0, sizeof(fallingspr));
10468 200 memset(shockedspr, 0, sizeof(shockedspr));
10469 200 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10470 200 memset(pullswordspr, 0, sizeof(pullswordspr));
10471 200 memset(readingspr, 0, sizeof(readingspr));
10472 200 memset(slash180spr, 0, sizeof(slash180spr));
10473 200 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10474 200 memset(dashspr, 0, sizeof(dashspr));
10475 200 memset(bonkspr, 0, sizeof(bonkspr));
10476 200 memset(medallionsprs, 0, sizeof(medallionsprs));
10477 200 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10478 200 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10479
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t q = 0; q < 4; ++q)
10480 {
10481
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 800 times.
3200 for(int32_t p = 0; p < 3; ++p)
10482 {
10483 2400 drowningspr[q][p] = divespr[q][p];
10484 2400 drowning_lavaspr[q][p] = divespr[q][p];
10485 2400 }
10486 800 }
10487 200 memset(sideswimspr, 0, sizeof(sideswimspr));
10488 200 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10489 200 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10490 200 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10491 200 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10492 200 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10493 200 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10494 200 }
10495
10496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if(FFCore.quest_format[vInitData] < 34)
10497 {
10498 305 bool fastswim = zinit.hero_swim_speed > 60;
10499 // '2/3' or '1/2'
10500 305 zinit.hero_swim_mult = fastswim ? 2 : 1;
10501 305 zinit.hero_swim_div = fastswim ? 3 : 2;
10502 305 }
10503 305 return 0;
10504 305 }
10505
10506 35700 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10507 {
10508 35700 arr[spr_tile] = tile;
10509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35700 times.
35700 arr[spr_flip] = (flip > 3 ? 0 : flip);
10510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35700 times.
35700 arr[spr_extend] = (ext > 2 ? 0 : ext);
10511 35700 }
10512 //Used to read the player sprites as int32_t, not word.
10513 210 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10514 {
10515 210 zinit.hero_swim_speed=67; //default
10516 210 setupherotiles(zinit.heroAnimationStyle);
10517 210 setupherodefenses();
10518 210 setupherooffsets();
10519
10520 int32_t tile, tile2;
10521 byte flip, extend, dummy_byte;
10522
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(v_herosprites>=0)
10524 {
10525
10526
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10527 {
10528
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10529 {
10530 return qe_invalid;
10531 }
10532
10533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10534 {
10535 return qe_invalid;
10536 }
10537
10538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10539 {
10540 return qe_invalid;
10541 }
10542
10543 840 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10544 840 }
10545
10546
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10547 {
10548
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10549 {
10550 return qe_invalid;
10551 }
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10559 {
10560 return qe_invalid;
10561 }
10562
10563 840 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10564 840 }
10565
10566
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10567 {
10568
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10569 {
10570 return qe_invalid;
10571 }
10572
10573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10574 {
10575 return qe_invalid;
10576 }
10577
10578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10579 {
10580 return qe_invalid;
10581 }
10582
10583 840 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10584 840 }
10585
10586
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10587 {
10588
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10589 {
10590 return qe_invalid;
10591 }
10592
10593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10594 {
10595 return qe_invalid;
10596 }
10597
10598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10599 {
10600 return qe_invalid;
10601 }
10602
10603 840 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10604 840 }
10605
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(v_herosprites>1)
10607 {
10608
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10609 {
10610
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10611 {
10612 return qe_invalid;
10613 }
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10616 {
10617 return qe_invalid;
10618 }
10619
10620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10621 {
10622 return qe_invalid;
10623 }
10624
10625 840 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10626 840 }
10627 210 }
10628
10629
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10630 {
10631
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10637 {
10638 return qe_invalid;
10639 }
10640
10641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10642 {
10643 return qe_invalid;
10644 }
10645
10646 840 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10647 840 }
10648
10649
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10650 {
10651
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10652 {
10653 return qe_invalid;
10654 }
10655
10656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10657 {
10658 return qe_invalid;
10659 }
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10662 {
10663 return qe_invalid;
10664 }
10665
10666 840 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10667 840 }
10668
10669
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&tile,f))
10670 {
10671 return qe_invalid;
10672 }
10673
10674 210 flip=0;
10675
10676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(v_herosprites>0)
10677 {
10678
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_getc(&flip,f))
10679 {
10680 return qe_invalid;
10681 }
10682 210 }
10683
10684
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_getc(&extend,f))
10685 {
10686 return qe_invalid;
10687 }
10688
10689 210 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10690
10691
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(v_herosprites>0)
10692 {
10693 210 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10694
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 210 times.
630 for(int32_t i=0; i<2; i++)
10695 {
10696
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 420 times.
1680 for(int32_t j=0; j<num_holdsprs; j++)
10697 {
10698
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 if(!p_igetl(&tile,f))
10699 {
10700 return qe_invalid;
10701 }
10702
10703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1260 times.
1260 if(!p_getc(&flip,f))
10704 {
10705 return qe_invalid;
10706 }
10707
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1260 times.
1260 if(!p_getc(&extend,f))
10709 {
10710 return qe_invalid;
10711 }
10712
10713 1260 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10714 1260 }
10715 420 }
10716 210 }
10717 else
10718 {
10719 for(int32_t i=0; i<2; i++)
10720 {
10721 if(!p_igetl(&tile,f))
10722 {
10723 return qe_invalid;
10724 }
10725
10726 if(!p_igetl(&tile2,f))
10727 {
10728 return qe_invalid;
10729 }
10730
10731 if(!p_getc(&extend,f))
10732 {
10733 return qe_invalid;
10734 }
10735
10736 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10737 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10738 }
10739 }
10740
10741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(v_herosprites>2)
10742 {
10743
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10744 {
10745
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10746 {
10747 return qe_invalid;
10748 }
10749
10750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10751 {
10752 return qe_invalid;
10753 }
10754
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10756 {
10757 return qe_invalid;
10758 }
10759
10760 840 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10761 840 }
10762 210 }
10763
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(v_herosprites>3)
10765 {
10766
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t i=0; i<4; i++)
10767 {
10768
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10769 {
10770 return qe_invalid;
10771 }
10772
10773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10774 {
10775 return qe_invalid;
10776 }
10777
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10779 {
10780 return qe_invalid;
10781 }
10782
10783 840 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10784 840 }
10785 210 }
10786
10787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(v_herosprites>4)
10788 {
10789
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_getc(&dummy_byte,f))
10790 {
10791 return qe_invalid;
10792 }
10793
10794 210 zinit.hero_swim_speed=(byte)dummy_byte;
10795 210 }
10796
10797
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(v_herosprites>6)
10798 {
10799
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10800 {
10801
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10802 return qe_invalid;
10803
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10805 return qe_invalid;
10806
10807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10808 return qe_invalid;
10809
10810 840 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10811 840 }
10812
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10813 {
10814
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10815 return qe_invalid;
10816
10817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10818 return qe_invalid;
10819
10820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10821 return qe_invalid;
10822
10823 840 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10824 840 }
10825
10826
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10827 {
10828
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10829 return qe_invalid;
10830
10831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10832 return qe_invalid;
10833
10834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10835 return qe_invalid;
10836
10837 840 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10838 840 }
10839
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10842 return qe_invalid;
10843
10844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10845 return qe_invalid;
10846
10847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10848 return qe_invalid;
10849
10850 840 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 840 }
10852
10853
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10854 {
10855
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10856 return qe_invalid;
10857
10858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10859 return qe_invalid;
10860
10861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10862 return qe_invalid;
10863
10864 840 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10865 840 }
10866
10867
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10868 {
10869
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10870 return qe_invalid;
10871
10872
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10873 return qe_invalid;
10874
10875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10876 return qe_invalid;
10877
10878 840 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10879 840 }
10880
10881
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10882 {
10883
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10884 return qe_invalid;
10885
10886
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10887 return qe_invalid;
10888
10889
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
10890 return qe_invalid;
10891
10892 840 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10893 840 }
10894
10895
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10896 {
10897
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10898 return qe_invalid;
10899
10900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
10901 return qe_invalid;
10902
10903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10904 return qe_invalid;
10905
10906 840 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10907 840 }
10908
10909
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10910 {
10911
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10915 return qe_invalid;
10916
10917
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
10918 return qe_invalid;
10919
10920 840 byte frames = 0;
10921
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 820 times.
840 if(v_herosprites > 15)
10922 {
10923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_getc(&frames,f))
10924 return qe_invalid;
10925 820 }
10926
10927 840 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10928 840 liftingspr[q][spr_frames] = frames;
10929 840 }
10930
10931
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10932 {
10933
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10934 return qe_invalid;
10935
10936
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10937 return qe_invalid;
10938
10939
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
10940 return qe_invalid;
10941
10942 840 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10943 840 }
10944
10945
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10946 {
10947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_igetl(&tile,f))
10948 return qe_invalid;
10949
10950
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10951 return qe_invalid;
10952
10953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10954 return qe_invalid;
10955
10956 840 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10957 840 }
10958
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10959 {
10960
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10961 return qe_invalid;
10962
10963
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10964 return qe_invalid;
10965
10966
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
10967 return qe_invalid;
10968
10969 840 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10970 840 }
10971
10972
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10973 {
10974
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10975 return qe_invalid;
10976
10977
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10978 return qe_invalid;
10979
10980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
10981 return qe_invalid;
10982
10983 840 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10984 840 }
10985
10986
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
10987 {
10988
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
10989 return qe_invalid;
10990
10991
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
10992 return qe_invalid;
10993
10994
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
10995 return qe_invalid;
10996
10997 840 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10998 840 }
10999
11000
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11001 {
11002
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11003 return qe_invalid;
11004
11005
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11006 return qe_invalid;
11007
11008
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11009 return qe_invalid;
11010
11011 840 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11012 840 }
11013
11014
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11015 {
11016
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11017 return qe_invalid;
11018
11019
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11020 return qe_invalid;
11021
11022
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11023 return qe_invalid;
11024
11025 840 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11026 840 }
11027
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11028 {
11029
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11030 return qe_invalid;
11031
11032
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11033 return qe_invalid;
11034
11035
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11036 return qe_invalid;
11037
11038 840 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11039 840 }
11040
11041
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11042 {
11043
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11044 return qe_invalid;
11045
11046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11047 return qe_invalid;
11048
11049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11050 return qe_invalid;
11051
11052 840 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11053 840 }
11054
11055
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11056 {
11057
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11058 return qe_invalid;
11059
11060
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11061 return qe_invalid;
11062
11063
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11064 return qe_invalid;
11065
11066 840 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11067 840 }
11068
11069
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11070 {
11071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_igetl(&tile,f))
11072 return qe_invalid;
11073
11074
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11075 return qe_invalid;
11076
11077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11078 return qe_invalid;
11079
11080 840 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11081 840 }
11082
11083
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11084 {
11085
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11086 return qe_invalid;
11087
11088
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11089 return qe_invalid;
11090
11091
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11092 return qe_invalid;
11093
11094 840 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11095 840 }
11096
11097
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11098 {
11099
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11100 return qe_invalid;
11101
11102
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11103 return qe_invalid;
11104
11105
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11106 return qe_invalid;
11107
11108 840 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11109 840 }
11110
11111
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11112 {
11113
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11114 return qe_invalid;
11115
11116
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&flip,f))
11117 return qe_invalid;
11118
11119
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_getc(&extend,f))
11120 return qe_invalid;
11121
11122 840 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11123 840 }
11124
11125
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 210 times.
840 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11126 {
11127
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetl(&tile,f))
11128 return qe_invalid;
11129
11130
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&flip,f))
11131 return qe_invalid;
11132
11133
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&extend,f))
11134 return qe_invalid;
11135
11136 630 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11137 630 }
11138 210 }
11139 else
11140 {
11141 memset(frozenspr, 0, sizeof(frozenspr));
11142 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11143 memset(onfirespr, 0, sizeof(onfirespr));
11144 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11145 memset(diggingspr, 0, sizeof(diggingspr));
11146 memset(usingrodspr, 0, sizeof(usingrodspr));
11147 memset(usingcanespr, 0, sizeof(usingcanespr));
11148 memset(pushingspr, 0, sizeof(pushingspr));
11149 memset(liftingspr, 0, sizeof(liftingspr));
11150 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11151 memset(stunnedspr, 0, sizeof(stunnedspr));
11152 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11153 memset(fallingspr, 0, sizeof(fallingspr));
11154 memset(shockedspr, 0, sizeof(shockedspr));
11155 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11156 memset(pullswordspr, 0, sizeof(pullswordspr));
11157 memset(readingspr, 0, sizeof(readingspr));
11158 memset(slash180spr, 0, sizeof(slash180spr));
11159 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11160 memset(dashspr, 0, sizeof(dashspr));
11161 memset(bonkspr, 0, sizeof(bonkspr));
11162 memset(medallionsprs, 0, sizeof(medallionsprs));
11163 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11164 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11165 for(int32_t q = 0; q < 4; ++q)
11166 {
11167 for(int32_t p = 0; p < 3; ++p)
11168 {
11169 drowningspr[q][p] = divespr[q][p];
11170 drowning_lavaspr[q][p] = divespr[q][p];
11171 }
11172 }
11173 }
11174
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 8)
11175 {
11176
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11177 {
11178
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11179 return qe_invalid;
11180
11181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11182 return qe_invalid;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11185 return qe_invalid;
11186
11187 840 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11188 840 }
11189 210 }
11190 else
11191 {
11192 memset(sideswimspr, 0, sizeof(sideswimspr));
11193 }
11194
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 9)
11195 {
11196
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11197 {
11198
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11199 return qe_invalid;
11200
11201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11202 return qe_invalid;
11203
11204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11205 return qe_invalid;
11206
11207 840 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11208 840 }
11209
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11210 {
11211
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11212 return qe_invalid;
11213
11214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11215 return qe_invalid;
11216
11217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11218 return qe_invalid;
11219
11220 840 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11221 840 }
11222
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11223 {
11224
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11225 return qe_invalid;
11226
11227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11228 return qe_invalid;
11229
11230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11231 return qe_invalid;
11232
11233 840 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11234 840 }
11235
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11236 {
11237
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11238 return qe_invalid;
11239
11240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11241 return qe_invalid;
11242
11243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11244 return qe_invalid;
11245
11246 840 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11247 840 }
11248 210 }
11249 else
11250 {
11251 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11252 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11253 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11254 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11255 }
11256
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 10)
11257 {
11258
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11259 {
11260 int32_t hmr;
11261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_igetl(&hmr,f))
11262 return qe_invalid;
11263
11264 840 hammeroffsets[q] = hmr;
11265 840 }
11266 210 }
11267 else
11268 {
11269 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11270 }
11271
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 11)
11272 {
11273
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 210 times.
840 for(int32_t q = 0; q < 3; ++q)
11274 {
11275
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetl(&tile,f))
11276 return qe_invalid;
11277
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(!p_getc(&flip,f))
11279 return qe_invalid;
11280
11281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(!p_getc(&extend,f))
11282 return qe_invalid;
11283
11284 630 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11285 630 }
11286 210 }
11287 else
11288 {
11289 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11290 }
11291
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 12)
11292 {
11293
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&tile,f))
11294 return qe_invalid;
11295
11296
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_getc(&flip,f))
11297 return qe_invalid;
11298
11299
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_getc(&extend,f))
11300 return qe_invalid;
11301 210 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11302
11303 210 }
11304 else
11305 {
11306 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11307 }
11308
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 13)
11309 {
11310
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11311 {
11312
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11313 return qe_invalid;
11314
11315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11316 return qe_invalid;
11317
11318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11319 return qe_invalid;
11320
11321 840 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11322 840 }
11323 210 }
11324 else
11325 {
11326 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11327 }
11328
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 14)
11329 {
11330
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 210 times.
1050 for(int32_t q = 0; q < 4; ++q)
11331 {
11332
1/2
✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
840 if(!p_igetl(&tile,f))
11333 return qe_invalid;
11334
11335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&flip,f))
11336 return qe_invalid;
11337
11338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&extend,f))
11339 return qe_invalid;
11340
11341 840 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11342 840 }
11343 210 }
11344 else
11345 {
11346 memset(revslashspr, 0, sizeof(revslashspr));
11347 }
11348
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if (v_herosprites > 7)
11349 {
11350 210 int32_t num_defense = wMax;
11351 210 byte def = 0;
11352
11353 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11354 /*if(v_herosprites > [x])
11355 * {
11356 * num_defense = 146 //value of wMax on version 8
11357 * }
11358 */
11359
11360
2/2
✓ Branch 0 taken 30660 times.
✓ Branch 1 taken 210 times.
30870 for (int32_t q = 0; q < num_defense; q++)
11361 {
11362
1/2
✓ Branch 0 taken 30660 times.
✗ Branch 1 not taken.
30660 if (!p_getc(&def, f))
11363 return qe_invalid;
11364
11365 30660 hero_defenses[q] = def;
11366 30660 }
11367 210 }
11368 else
11369 {
11370 int32_t num_defense = wMax;
11371 for (int32_t q = 0; q < num_defense; q++)
11372 {
11373 hero_defenses[q] = 0;
11374 }
11375 }
11376 210 }
11377
11378
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 11 times.
210 if(FFCore.quest_format[vInitData] < 34)
11379 {
11380 11 bool fastswim = zinit.hero_swim_speed > 60;
11381 // '2/3' or '1/2'
11382 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11383 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11384 11 }
11385 210 return 0;
11386 210 }
11387
11388
11389 410 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11390 {
11391 //these are here to bypass compiler warnings about unused arguments
11392 410 Header=Header;
11393
11394 dword dummy;
11395 410 word s_version=0;
11396
11397 //section version info
11398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(!p_igetw(&s_version,f))
11399 {
11400 return qe_invalid;
11401 }
11402
11403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_HEROSPRITES)
11404 return qe_version;
11405
11406 410 FFCore.quest_format[vHeroSprites] = s_version;
11407
11408
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
11409 {
11410 return qe_invalid;
11411 }
11412
11413 //section size
11414
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&dummy,f))
11415 {
11416 return qe_invalid;
11417 }
11418
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if ( s_version >= 6 )
11419 {
11420 210 return readherosprites3(f, s_version);
11421 }
11422 200 else return readherosprites2(f, s_version);
11423 410 }
11424
11425 217 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11426 {
11427 217 subscreens_active.clear();
11428 217 subscreens_passive.clear();
11429 217 subscreens_overlay.clear();
11430 217 subscreens_map.clear();
11431
2/2
✓ Branch 0 taken 27776 times.
✓ Branch 1 taken 217 times.
27993 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11432 {
11433 subscreen_group g;
11434 27776 memset(&g,0,sizeof(subscreen_group));
11435 27776 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(ret!=0)
11437 return ret;
11438
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 26659 times.
27776 if(g.objects[0].type == ssoNULL) continue;
11439
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 650 times.
1117 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11440 1117 ZCSubscreen& sub = vec.emplace_back();
11441 1117 sub.load_old(g);
11442 1117 }
11443
11444 217 return 0;
11445 217 }
11446
11447 27776 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11448 {
11449 27776 int32_t numsub=0;
11450 27776 byte temp_ss=0;
11451 subscreen_object temp_sub_stack;
11452 27776 subscreen_object *temp_sub = &temp_sub_stack;
11453
11454 char tempname[64];
11455
11456 // FWIW I never saw anything bigger than 20.
11457 #define MAX_DP1_LEN 1024
11458 char tempdp1[MAX_DP1_LEN];
11459
11460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(!pfread(tempname,64,f))
11461 {
11462 return qe_invalid;
11463 }
11464
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version > 1)
11466 {
11467
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_getc(&temp_ss,f))
11468 {
11469 return qe_invalid;
11470 }
11471 27776 }
11472
11473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version < 4)
11474 {
11475 uint8_t tmp=0;
11476
11477 if(!p_getc(&tmp,f))
11478 {
11479 return qe_invalid;
11480 }
11481
11482 numsub = (int32_t)tmp;
11483 }
11484 else
11485 {
11486 word tmp;
11487
11488
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_igetw(&tmp, f))
11489 {
11490 return qe_invalid;
11491 }
11492
11493 27776 numsub = (int32_t)tmp;
11494 }
11495
11496 int32_t j;
11497
11498
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71950 times.
✓ Branch 2 taken 44174 times.
✓ Branch 3 taken 27776 times.
71950 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11499 {
11500 44174 memset(temp_sub,0,sizeof(subscreen_object));
11501
11502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 switch(g->objects[j].type)
11503 {
11504 case ssoTEXT:
11505 case ssoTEXTBOX:
11506 case ssoCURRENTITEMTEXT:
11507 case ssoCURRENTITEMCLASSTEXT:
11508 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11509
11510 //fall through
11511 default:
11512 44174 memset(&g->objects[j],0,sizeof(subscreen_object));
11513 44174 break;
11514 }
11515
11516
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->type),f))
11517 return qe_invalid;
11518
11519
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->pos),f))
11520 return qe_invalid;
11521
11522
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(s_version < 5)
11523 {
11524 switch(temp_sub->pos)
11525 {
11526 case 0:
11527 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11528 break;
11529
11530 case 1:
11531 temp_sub->pos = sspUP;
11532 break;
11533
11534 case 2:
11535 temp_sub->pos = sspDOWN;
11536 break;
11537
11538 default:
11539 temp_sub->pos = 0;
11540 }
11541 }
11542
11543
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->x),f))
11544 return qe_invalid;
11545
11546
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->y),f))
11547 return qe_invalid;
11548
11549
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->w),f))
11550 return qe_invalid;
11551
11552
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->h),f))
11553 return qe_invalid;
11554
11555
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype1),f))
11556 return qe_invalid;
11557
11558
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color1),f))
11559 return qe_invalid;
11560
11561
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype2),f))
11562 return qe_invalid;
11563
11564
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color2),f))
11565 return qe_invalid;
11566
11567
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype3),f))
11568 return qe_invalid;
11569
11570
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color3),f))
11571 return qe_invalid;
11572
11573
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d1),f))
11574 return qe_invalid;
11575
11576
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d2),f))
11577 return qe_invalid;
11578
11579
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d3),f))
11580 return qe_invalid;
11581
11582
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d4),f))
11583 return qe_invalid;
11584
11585
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d5),f))
11586 return qe_invalid;
11587
11588
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d6),f))
11589 return qe_invalid;
11590
11591
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d7),f))
11592 return qe_invalid;
11593
11594
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d8),f))
11595 return qe_invalid;
11596
11597
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d9),f))
11598 return qe_invalid;
11599
11600
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d10),f))
11601 return qe_invalid;
11602
11603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 if(s_version < 2)
11604 {
11605 if(!p_igetl(&(temp_sub->speed),f))
11606 return qe_invalid;
11607
11608 if(!p_igetl(&(temp_sub->delay),f))
11609 return qe_invalid;
11610
11611 if(!p_igetl(&(temp_sub->frame),f))
11612 return qe_invalid;
11613 }
11614 else
11615 {
11616
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->speed),f))
11617 return qe_invalid;
11618
11619
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->delay),f))
11620 return qe_invalid;
11621
11622
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->frame),f))
11623 return qe_invalid;
11624 }
11625
11626 44174 int32_t temp_size=0;
11627
11628 // bool deletets = false;
11629
4/4
✓ Branch 0 taken 19541 times.
✓ Branch 1 taken 3389 times.
✓ Branch 2 taken 21002 times.
✓ Branch 3 taken 242 times.
44174 switch(temp_sub->type)
11630 {
11631 case ssoTEXT:
11632 case ssoTEXTBOX:
11633 case ssoCURRENTITEMTEXT:
11634 case ssoCURRENTITEMCLASSTEXT:
11635 {
11636 word temptempsize;
11637
11638
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!p_igetw(&temptempsize,f))
11639 {
11640 return qe_invalid;
11641 }
11642
11643 //temptempsize = temp1 + (temp2 << 8);
11644 3389 temp_size = (int32_t)temptempsize;
11645 3389 uint32_t char_length = temp_size+2;
11646
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if (char_length > MAX_DP1_LEN)
11647 {
11648 return qe_invalid;
11649 }
11650 3389 tempdp1[char_length - 1] = '\0';
11651
11652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
3389 if(temp_size)
11653
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!pfread(tempdp1,temp_size+1,f))
11654 return qe_invalid;
11655 3389 break;
11656 }
11657
11658 case ssoLIFEMETER:
11659
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11660 temp_sub->d3 = 1;
11661
11662
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(!p_getc(&(temp_sub->dp1),f))
11663 return qe_invalid;
11664
11665 242 break;
11666
11667
11668 case ssoCURRENTITEM:
11669
11670
1/2
✓ Branch 0 taken 19541 times.
✗ Branch 1 not taken.
19541 if(s_version < 6)
11671 {
11672 switch(temp_sub->d1)
11673 {
11674 case ssiBOMB:
11675 temp_sub->d1 = itype_bomb;
11676 break;
11677
11678 case ssiSWORD:
11679 temp_sub->d1 = itype_sword;
11680 break;
11681
11682 case ssiSHIELD:
11683 temp_sub->d1 = itype_shield;
11684 break;
11685
11686 case ssiCANDLE:
11687 temp_sub->d1 = itype_candle;
11688 break;
11689
11690 case ssiLETTER:
11691 temp_sub->d1 = itype_letter;
11692 break;
11693
11694 case ssiPOTION:
11695 temp_sub->d1 = itype_potion;
11696 break;
11697
11698 case ssiLETTERPOTION:
11699 temp_sub->d1 = itype_letterpotion;
11700 break;
11701
11702 case ssiBOW:
11703 temp_sub->d1 = itype_bow;
11704 break;
11705
11706 case ssiARROW:
11707 temp_sub->d1 = itype_arrow;
11708 break;
11709
11710 case ssiBOWANDARROW:
11711 temp_sub->d1 = itype_bowandarrow;
11712 break;
11713
11714 case ssiBAIT:
11715 temp_sub->d1 = itype_bait;
11716 break;
11717
11718 case ssiRING:
11719 temp_sub->d1 = itype_ring;
11720 break;
11721
11722 case ssiBRACELET:
11723 temp_sub->d1 = itype_bracelet;
11724 break;
11725
11726 case ssiMAP:
11727 temp_sub->d1 = itype_map;
11728 break;
11729
11730 case ssiCOMPASS:
11731 temp_sub->d1 = itype_compass;
11732 break;
11733
11734 case ssiBOSSKEY:
11735 temp_sub->d1 = itype_bosskey;
11736 break;
11737
11738 case ssiMAGICKEY:
11739 temp_sub->d1 = itype_magickey;
11740 break;
11741
11742 case ssiBRANG:
11743 temp_sub->d1 = itype_brang;
11744 break;
11745
11746 case ssiWAND:
11747 temp_sub->d1 = itype_wand;
11748 break;
11749
11750 case ssiRAFT:
11751 temp_sub->d1 = itype_raft;
11752 break;
11753
11754 case ssiLADDER:
11755 temp_sub->d1 = itype_ladder;
11756 break;
11757
11758 case ssiWHISTLE:
11759 temp_sub->d1 = itype_whistle;
11760 break;
11761
11762 case ssiBOOK:
11763 temp_sub->d1 = itype_book;
11764 break;
11765
11766 case ssiWALLET:
11767 temp_sub->d1 = itype_wallet;
11768 break;
11769
11770 case ssiSBOMB:
11771 temp_sub->d1 = itype_sbomb;
11772 break;
11773
11774 case ssiHCPIECE:
11775 temp_sub->d1 = itype_heartpiece;
11776 break;
11777
11778 case ssiAMULET:
11779 temp_sub->d1 = itype_amulet;
11780 break;
11781
11782 case ssiFLIPPERS:
11783 temp_sub->d1 = itype_flippers;
11784 break;
11785
11786 case ssiHOOKSHOT:
11787 temp_sub->d1 = itype_hookshot;
11788 break;
11789
11790 case ssiLENS:
11791 temp_sub->d1 = itype_lens;
11792 break;
11793
11794 case ssiHAMMER:
11795 temp_sub->d1 = itype_hammer;
11796 break;
11797
11798 case ssiBOOTS:
11799 temp_sub->d1 = itype_boots;
11800 break;
11801
11802 case ssiDIVINEFIRE:
11803 temp_sub->d1 = itype_divinefire;
11804 break;
11805
11806 case ssiDIVINEESCAPE:
11807 temp_sub->d1 = itype_divineescape;
11808 break;
11809
11810 case ssiDIVINEPROTECTION:
11811 temp_sub->d1 = itype_divineprotection;
11812 break;
11813
11814 case ssiQUIVER:
11815 temp_sub->d1 = itype_quiver;
11816 break;
11817
11818 case ssiBOMBBAG:
11819 temp_sub->d1 = itype_bombbag;
11820 break;
11821
11822 case ssiCBYRNA:
11823 temp_sub->d1 = itype_cbyrna;
11824 break;
11825
11826 case ssiROCS:
11827 temp_sub->d1 = itype_rocs;
11828 break;
11829
11830 case ssiHOVERBOOTS:
11831 temp_sub->d1 = itype_hoverboots;
11832 break;
11833
11834 case ssiSPINSCROLL:
11835 temp_sub->d1 = itype_spinscroll;
11836 break;
11837
11838 case ssiCROSSSCROLL:
11839 temp_sub->d1 = itype_crossscroll;
11840 break;
11841
11842 case ssiQUAKESCROLL:
11843 temp_sub->d1 = itype_quakescroll;
11844 break;
11845
11846 case ssiWHISPRING:
11847 temp_sub->d1 = itype_whispring;
11848 break;
11849
11850 case ssiCHARGERING:
11851 temp_sub->d1 = itype_chargering;
11852 break;
11853
11854 case ssiPERILSCROLL:
11855 temp_sub->d1 = itype_perilscroll;
11856 break;
11857
11858 case ssiWEALTHMEDAL:
11859 temp_sub->d1 = itype_wealthmedal;
11860 break;
11861
11862 case ssiHEARTRING:
11863 temp_sub->d1 = itype_heartring;
11864 break;
11865
11866 case ssiMAGICRING:
11867 temp_sub->d1 = itype_magicring;
11868 break;
11869
11870 case ssiSPINSCROLL2:
11871 temp_sub->d1 = itype_spinscroll2;
11872 break;
11873
11874 case ssiQUAKESCROLL2:
11875 temp_sub->d1 = itype_quakescroll2;
11876 break;
11877
11878 case ssiAGONY:
11879 temp_sub->d1 = itype_agony;
11880 break;
11881
11882 case ssiSTOMPBOOTS:
11883 temp_sub->d1 = itype_stompboots;
11884 break;
11885
11886 case ssiWHIMSICALRING:
11887 temp_sub->d1 = itype_whimsicalring;
11888 break;
11889
11890 case ssiPERILRING:
11891 temp_sub->d1 = itype_perilring;
11892 break;
11893
11894 default:
11895 temp_sub->d1 += itype_custom1 - ssiMAX;
11896 }
11897 }
11898
11899 //fall-through
11900 default:
11901
1/2
✓ Branch 0 taken 40543 times.
✗ Branch 1 not taken.
40543 if(!p_getc(&(temp_sub->dp1),f))
11902 return qe_invalid;
11903
11904 40543 break;
11905 }
11906
11907
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 35480 times.
44174 if(s_version < 7)
11908 {
11909
3/3
✓ Branch 0 taken 29642 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 4568 times.
35480 switch(temp_sub->type)
11910 {
11911 case ssoMAGICGAUGE:
11912 {
11913
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1136 times.
1270 if(!temp_sub->d9)
11914 1136 temp_sub->d9 = -1; //-1 now represents 'always'
11915 1270 break;
11916 }
11917 case ssoLIFEGAUGE:
11918 4568 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11919 4568 break;
11920 }
11921 35480 }
11922
11923
3/3
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 39307 times.
✓ Branch 2 taken 1478 times.
44174 switch(temp_sub->type)
11924 {
11925 case ssoTEXT:
11926 case ssoTEXTBOX:
11927 case ssoCURRENTITEMTEXT:
11928 case ssoCURRENTITEMCLASSTEXT:
11929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3389 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11930
11931 3389 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11932 3389 g->objects[j].dp1 = new char[temp_size+2];
11933 3389 strcpy((char*)g->objects[j].dp1,tempdp1);
11934 3389 break;
11935
11936 case ssoCOUNTER:
11937
1/2
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
1478 if(s_version<3)
11938 {
11939 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11940 temp_sub->d8=0;
11941 }
11942
11943 default:
11944 40785 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11945 40785 break;
11946 }
11947
11948 44174 g->name[0] = '\0';
11949 44174 strncat(g->name, tempname, 64 - 1);
11950 44174 g->ss_type = temp_ss;
11951 44174 }
11952
11953
2/2
✓ Branch 0 taken 7066482 times.
✓ Branch 1 taken 27776 times.
7094258 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11954 {
11955 //clear all unused object in this subscreen -DD
11956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066482 times.
7066482 switch(g->objects[j].type)
11957 {
11958 case ssoTEXT:
11959 case ssoTEXTBOX:
11960 case ssoCURRENTITEMTEXT:
11961 case ssoCURRENTITEMCLASSTEXT:
11962 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11963
11964 //fall through
11965 default:
11966 7066482 memset(&g->objects[j],0,sizeof(subscreen_object));
11967 7066482 break;
11968 }
11969 7066482 }
11970
11971 27776 return 0;
11972 27776 }
11973
11974 410 int32_t readsubscreens(PACKFILE *f)
11975 {
11976 word s_version;
11977 dword dummy;
11978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(!p_igetw(&s_version,f))
11979 return qe_invalid;
11980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_SUBSCREEN)
11981 return qe_version;
11982 410 FFCore.quest_format[vSubscreen] = s_version;
11983
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
11984 return qe_invalid;
11985
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&dummy,f)) //section size
11986 return qe_invalid;
11987
11988
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 193 times.
410 if(s_version < 8)
11989 217 return read_old_subscreens(f,s_version);
11990
11991 193 subscreens_active.clear();
11992 193 subscreens_passive.clear();
11993 193 subscreens_overlay.clear();
11994 193 subscreens_map.clear();
11995
11996 byte sz;
11997
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_getc(&sz,f))
11998 return qe_invalid;
11999
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 193 times.
800 for(byte q = 0; q < sz; ++q)
12000 {
12001 607 ZCSubscreen& tmp = subscreens_active.emplace_back();
12002
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if (auto ret = tmp.read(f, s_version))
12003 return ret;
12004 607 }
12005
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_getc(&sz,f))
12006 return qe_invalid;
12007
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 193 times.
925 for(byte q = 0; q < sz; ++q)
12008 {
12009 732 ZCSubscreen& tmp = subscreens_passive.emplace_back();
12010
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if (auto ret = tmp.read(f, s_version))
12011 return ret;
12012 732 }
12013
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_getc(&sz,f))
12014 return qe_invalid;
12015
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 193 times.
203 for(byte q = 0; q < sz; ++q)
12016 {
12017 10 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
12018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (auto ret = tmp.read(f, s_version))
12019 return ret;
12020 10 }
12021
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 75 times.
193 if (s_version >= 16)
12022 {
12023
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&sz,f))
12024 return qe_invalid;
12025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 for(byte q = 0; q < sz; ++q)
12026 {
12027 ZCSubscreen& tmp = subscreens_map.emplace_back();
12028 if (auto ret = tmp.read(f, s_version))
12029 return ret;
12030 }
12031 75 }
12032 193 return 0;
12033 410 }
12034
12035 void reset_subscreen(subscreen_group *tempss)
12036 {
12037 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12038 {
12039 switch(tempss->objects[i].type)
12040 {
12041 case ssoTEXT:
12042 case ssoTEXTBOX:
12043 case ssoCURRENTITEMTEXT:
12044 case ssoCURRENTITEMCLASSTEXT:
12045 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12046
12047 //fall through
12048 default:
12049 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12050 break;
12051 }
12052 }
12053 }
12054
12055 117 void reset_subscreens()
12056 {
12057 117 subscreens_active.clear();
12058 117 subscreens_passive.clear();
12059 117 subscreens_overlay.clear();
12060 117 subscreens_map.clear();
12061 117 }
12062
12063 117 int32_t setupsubscreens()
12064 {
12065 117 reset_subscreens();
12066 //return 0;
12067
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12068 {
12069 234 subscreens_active.emplace_back();
12070 234 subscreens_passive.emplace_back();
12071 234 }
12072 117 int32_t tempsubscreen=subscr_mode;
12073
12074
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12075 tempsubscreen=0;
12076
12077
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12078 {
12079 case ssdtOLD:
12080 case ssdtNEWSUBSCR:
12081 case ssdtREV2:
12082 case ssdtBSZELDA:
12083 case ssdtBSZELDAMODIFIED:
12084 case ssdtBSZELDAENHANCED:
12085 case ssdtBSZELDACOMPLETE:
12086 {
12087 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12088 117 subscreens_active[0].sub_type=sstACTIVE;
12089 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12090 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12091 117 subscreens_active[1].sub_type=sstACTIVE;
12092 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12093 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12094 117 subscreens_passive[0].sub_type=sstPASSIVE;
12095 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12096 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12097 117 subscreens_passive[1].sub_type=sstPASSIVE;
12098 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12099 117 break;
12100 }
12101
12102 case ssdtZ3:
12103 {
12104 subscreens_active[0].load_old(z3_active_a);
12105 subscreens_active[0].sub_type=sstACTIVE;
12106 subscreens_active[1].load_old(z3_active_ab);
12107 subscreens_active[1].sub_type=sstACTIVE;
12108 subscreens_passive[0].load_old(z3_passive_a);
12109 subscreens_passive[0].sub_type=sstPASSIVE;
12110 subscreens_passive[1].load_old(z3_passive_ab);
12111 subscreens_passive[1].sub_type=sstPASSIVE;
12112 break;
12113 }
12114 }
12115 117 subscr_mode = ssdtMAX;
12116 117 return 0;
12117 }
12118
12119 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12120
12121 extern script_data *ffscripts[NUMSCRIPTFFC];
12122 extern script_data *itemscripts[NUMSCRIPTITEM];
12123 extern script_data *guyscripts[NUMSCRIPTGUYS];
12124 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12125 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12126 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12127 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12128 extern script_data *playerscripts[NUMSCRIPTHERO];
12129 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12130 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12131 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12132 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12133 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12134
12135 static std::vector<const script_data*> read_scripts;
12136
12137 439 static script_data fake_script_data(ScriptType::None, 0);
12138
12139 528 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12140 {
12141 int32_t dummy;
12142 528 word s_version=0, zmeta_version=0;
12143 528 byte numscripts=0;
12144 528 numscripts=numscripts; //to avoid unused variables warnings
12145 int32_t ret;
12146 528 read_scripts.clear();
12147 528 zasm_scripts.clear();
12148
12149 //section version info
12150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_igetw(&s_version,f))
12151 {
12152 return qe_invalid;
12153 }
12154
12155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if (s_version > V_FFSCRIPT)
12156 return qe_version;
12157
12158 528 FFCore.quest_format[vFFScript] = s_version;
12159
12160
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!read_deprecated_section_cversion(f))
12161 {
12162 return qe_invalid;
12163 }
12164
12165
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 210 times.
528 if(s_version >= 18)
12166 {
12167
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetw(&zmeta_version,f))
12168 {
12169 return qe_invalid;
12170 }
12171 210 }
12172
12173 //section size
12174
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetl(&dummy,f))
12175 {
12176 return qe_invalid;
12177 }
12178
12179
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 219 times.
528 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12180 528 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12181
12182
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 144 times.
528 if(s_version >= 27)
12183 {
12184 144 ret = read_quest_zasm(f, s_version);
12185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(ret)
12186 return qe_invalid;
12187 144 }
12188
12189 //finally... section data
12190
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 446 times.
210366 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12191 {
12192 209920 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12193
12194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
209920 if (ret)
12195 {
12196 return qe_invalid;
12197 }
12198 209920 }
12199
12200 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12201 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12202 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12203 * there was a version bump a week before a change that broke stuff.
12204 */
12205
7/8
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 210 times.
✓ Branch 4 taken 210 times.
✓ Branch 5 taken 210 times.
✓ Branch 6 taken 210 times.
✓ Branch 7 taken 210 times.
446 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12206 {
12207 656 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12208 656 }
12209
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if(s_version < 19)
12210 {
12211 200 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12212 200 }
12213
12214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(s_version > 1)
12215 {
12216
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12217 {
12218 104960 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12219
12220
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if (ret)
12221 {
12222 return qe_invalid;
12223 }
12224 104960 }
12225
12226
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12227 {
12228 104960 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12229
12230
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if (ret)
12231 {
12232 return qe_invalid;
12233 }
12234 104960 }
12235
12236
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12237 {
12238 104960 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12239
12240
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if (ret)
12241 {
12242 return qe_invalid;
12243 }
12244 104960 }
12245
12246
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12247 {
12248 104960 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12249
12250
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if (ret)
12251 {
12252 return qe_invalid;
12253 }
12254 104960 }
12255
12256
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if(s_version > 16)
12257 {
12258
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 210 times.
1890 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12259 {
12260 1680 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12261
12262
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 if (ret)
12263 {
12264 return qe_invalid;
12265 }
12266 1680 }
12267 210 }
12268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 else if(s_version > 13)
12269 {
12270 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12271 {
12272 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12273
12274 if (ret)
12275 {
12276 return qe_invalid;
12277 }
12278 }
12279
12280 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12281 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12282
12283 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12284 }
12285
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 else if(s_version > 4)
12286 {
12287
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12288 {
12289 800 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12290
12291
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (ret)
12292 {
12293 return qe_invalid;
12294 }
12295 800 }
12296
12297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12298
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12299
12300
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12301
12302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12303
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12304
12305
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12306
12307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12308
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_F6];
12309
12310
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12311
12312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12313
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12314
12315
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12316 200 }
12317 else
12318 {
12319 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12320 {
12321 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12322
12323 if (ret)
12324 {
12325 return qe_invalid;
12326 }
12327 }
12328
12329 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12330 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12331
12332 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12333
12334 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12335 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12336
12337 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12338
12339 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12340 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12341
12342 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12343
12344 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12345 delete globalscripts[GLOBAL_SCRIPT_F6];
12346
12347 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12348
12349 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12350 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12351
12352 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12353 }
12354
12355
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if(s_version > 10) //expanded the number of Hero scripts to 5.
12356 {
12357
2/2
✓ Branch 0 taken 1050 times.
✓ Branch 1 taken 210 times.
1260 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12358 {
12359 1050 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12360
12361
1/2
✓ Branch 0 taken 1050 times.
✗ Branch 1 not taken.
1050 if (ret)
12362 {
12363 return qe_invalid;
12364 }
12365 1050 }
12366 210 }
12367 else
12368 {
12369
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 200 times.
800 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12370 {
12371 600 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12372
12373
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 if (ret)
12374 {
12375 return qe_invalid;
12376 }
12377 600 }
12378
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[3] != NULL)
12379
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete playerscripts[3];
12380
12381
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12382
12383
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[4] != NULL)
12384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 delete playerscripts[4];
12385
12386
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12387 }
12388
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
410 if(s_version > 8 && s_version < 10)
12389 {
12390
12391 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12392 {
12393 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12394
12395 if (ret)
12396 {
12397 return qe_invalid;
12398 }
12399 }
12400 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12401 {
12402 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12403
12404 if (ret)
12405 {
12406 return qe_invalid;
12407 }
12408 }
12409
12410 }
12411
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version >= 10)
12412 {
12413
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12414 {
12415 53760 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12416
12417
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if (ret)
12418 {
12419 return qe_invalid;
12420 }
12421 53760 }
12422
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12423 {
12424 53760 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12425
12426
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if (ret)
12427 {
12428 return qe_invalid;
12429 }
12430 53760 }
12431
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12432 {
12433 53760 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12434
12435
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if (ret)
12436 {
12437 return qe_invalid;
12438 }
12439 53760 }
12440
12441 210 }
12442
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version >=12)
12443 {
12444
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12445 {
12446 53760 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12447
12448
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if (ret)
12449 {
12450 return qe_invalid;
12451 }
12452 53760 }
12453 210 }
12454
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version >=15)
12455 {
12456
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 210 times.
107730 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12457 {
12458 107520 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12459
12460
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if (ret)
12461 {
12462 return qe_invalid;
12463 }
12464 107520 }
12465 210 }
12466
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version >19)
12467 {
12468 210 word numgenscripts = NUMSCRIPTSGENERIC;
12469
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetw(&numgenscripts,f))
12470 {
12471 return qe_invalid;
12472 }
12473
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 210 times.
107730 for(int32_t i = 0; i < numgenscripts; i++)
12474 {
12475 107520 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12476
12477
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if (ret)
12478 {
12479 return qe_invalid;
12480 }
12481 107520 }
12482 210 }
12483
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 193 times.
410 if(s_version >21)
12484 {
12485 193 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12486
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_igetw(&numsubscripts,f))
12487 {
12488 return qe_invalid;
12489 }
12490
2/2
✓ Branch 0 taken 49408 times.
✓ Branch 1 taken 193 times.
49601 for(int32_t i = 0; i < numsubscripts; i++)
12491 {
12492 49408 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12493
12494
1/2
✓ Branch 0 taken 49408 times.
✗ Branch 1 not taken.
49408 if (ret)
12495 {
12496 return qe_invalid;
12497 }
12498 49408 }
12499 193 }
12500 410 }
12501
12502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(s_version > 2)
12503 {
12504 int32_t bufsize;
12505 410 p_igetl(&bufsize, f);
12506
2/4
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
410 if (bufsize < 0 || bufsize > 1024*1024*10)
12507 {
12508 // God help anyone storing more than 10MB of code in the script buffer.
12509 return qe_invalid;
12510 }
12511 410 char * buf = new char[bufsize+1];
12512 410 pfread(buf, bufsize, f);
12513 410 buf[bufsize]=0;
12514
12515
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 zScript = string(buf);
12516
12517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 delete[] buf;
12518 word numffcbindings;
12519 410 p_igetw(&numffcbindings, f);
12520
12521
2/2
✓ Branch 0 taken 11787 times.
✓ Branch 1 taken 410 times.
12197 for(int32_t i=0; i<numffcbindings; i++)
12522 {
12523 word id;
12524 11787 p_igetw(&id, f);
12525 11787 p_igetl(&bufsize, f);
12526
2/4
✓ Branch 0 taken 11787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11787 times.
11787 if (bufsize < 0 || bufsize > 1024)
12527 return qe_invalid;
12528 11787 buf = new char[bufsize+1];
12529 11787 pfread(buf, bufsize, f);
12530 11787 buf[bufsize]=0;
12531
12532 //fix for buggy older saved quests -DD
12533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11787 times.
11787 if(id < NUMSCRIPTFFC-1)
12534 11787 ffcmap[id].scriptname = buf;
12535
12536
1/2
✓ Branch 0 taken 11787 times.
✗ Branch 1 not taken.
11787 delete[] buf;
12537 11787 }
12538
12539 word numglobalbindings;
12540 410 p_igetw(&numglobalbindings, f);
12541
12542
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 410 times.
2073 for(int32_t i=0; i<numglobalbindings; i++)
12543 {
12544 word id;
12545 1663 p_igetw(&id, f);
12546 1663 p_igetl(&bufsize, f);
12547
2/4
✓ Branch 0 taken 1663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1663 times.
✗ Branch 3 not taken.
1663 if (bufsize < 0 || bufsize > 1024)
12548 return qe_invalid;
12549 1663 buf = new char[bufsize+1];
12550 1663 pfread(buf, bufsize, f);
12551 1663 buf[bufsize]=0;
12552
12553 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12554 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12555 // Ignore these. -DD
12556
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1117 times.
1663 if (id < NUMSCRIPTGLOBAL)
12557 {
12558 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12559
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(strcmp(buf,"~Continue") == 0)
12560 {
12561 globalmap[id].scriptname = "";
12562
12563 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12564 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12565 }
12566 else
12567 {
12568 1117 globalmap[id].scriptname = buf;
12569 }
12570 1117 }
12571
12572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1663 times.
1663 delete[] buf;
12573 1663 }
12574
12575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(s_version > 3)
12576 {
12577 word numitembindings;
12578 410 p_igetw(&numitembindings, f);
12579
12580
2/2
✓ Branch 0 taken 1387 times.
✓ Branch 1 taken 410 times.
1797 for(int32_t i=0; i<numitembindings; i++)
12581 {
12582 word id;
12583 1387 p_igetw(&id, f);
12584 1387 p_igetl(&bufsize, f);
12585
2/4
✓ Branch 0 taken 1387 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1387 times.
1387 if (bufsize < 0 || bufsize > 1024)
12586 return qe_invalid;
12587 1387 buf = new char[bufsize+1];
12588 1387 pfread(buf, bufsize, f);
12589 1387 buf[bufsize]=0;
12590
12591 //fix this too
12592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1387 times.
1387 if(id <NUMSCRIPTITEM-1)
12593 1387 itemmap[id].scriptname = buf;
12594
12595
1/2
✓ Branch 0 taken 1387 times.
✗ Branch 1 not taken.
1387 delete[] buf;
12596 1387 }
12597 410 }
12598 //(v9+)
12599
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version > 8)
12600 {
12601 //npc scripts
12602 word numnpcbindings;
12603 210 p_igetw(&numnpcbindings, f);
12604
12605
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 210 times.
402 for(int32_t i=0; i<numnpcbindings; i++)
12606 {
12607 word id;
12608 192 p_igetw(&id, f);
12609 192 p_igetl(&bufsize, f);
12610
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if (bufsize < 0 || bufsize > 1024)
12611 return qe_invalid;
12612 192 buf = new char[bufsize+1];
12613 192 pfread(buf, bufsize, f);
12614 192 buf[bufsize]=0;
12615
12616 //fix this too
12617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(id <NUMSCRIPTGUYS-1)
12618 192 npcmap[id].scriptname = buf;
12619
12620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 delete[] buf;
12621 192 }
12622 //lweapon
12623 word numlwpnbindings;
12624 210 p_igetw(&numlwpnbindings, f);
12625
12626
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 210 times.
639 for(int32_t i=0; i<numlwpnbindings; i++)
12627 {
12628 word id;
12629 429 p_igetw(&id, f);
12630 429 p_igetl(&bufsize, f);
12631
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 429 times.
429 if (bufsize < 0 || bufsize > 1024)
12632 return qe_invalid;
12633 429 buf = new char[bufsize+1];
12634 429 pfread(buf, bufsize, f);
12635 429 buf[bufsize]=0;
12636
12637 //fix this too
12638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(id <NUMSCRIPTWEAPONS-1)
12639 429 lwpnmap[id].scriptname = buf;
12640
12641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 delete[] buf;
12642 429 }
12643 //eweapon
12644 word numewpnbindings;
12645 210 p_igetw(&numewpnbindings, f);
12646
12647
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 210 times.
647 for(int32_t i=0; i<numewpnbindings; i++)
12648 {
12649 word id;
12650 437 p_igetw(&id, f);
12651 437 p_igetl(&bufsize, f);
12652
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12653 return qe_invalid;
12654 437 buf = new char[bufsize+1];
12655 437 pfread(buf, bufsize, f);
12656 437 buf[bufsize]=0;
12657
12658 //fix this too
12659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(id <NUMSCRIPTWEAPONS-1)
12660 437 ewpnmap[id].scriptname = buf;
12661
12662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12663 437 }
12664 //hero
12665 word numherobindings;
12666 210 p_igetw(&numherobindings, f);
12667
12668
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 210 times.
253 for(int32_t i=0; i<numherobindings; i++)
12669 {
12670 word id;
12671 43 p_igetw(&id, f);
12672 43 p_igetl(&bufsize, f);
12673
2/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
43 if (bufsize < 0 || bufsize > 1024)
12674 return qe_invalid;
12675 43 buf = new char[bufsize+1];
12676 43 pfread(buf, bufsize, f);
12677 43 buf[bufsize]=0;
12678
12679 //fix this too
12680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(id <NUMSCRIPTHERO-1)
12681 43 playermap[id].scriptname = buf;
12682
12683
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 delete[] buf;
12684 43 }
12685 //dmaps
12686 word numdmapbindings;
12687 210 p_igetw(&numdmapbindings, f);
12688
12689
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 210 times.
759 for(int32_t i=0; i<numdmapbindings; i++)
12690 {
12691 word id;
12692 549 p_igetw(&id, f);
12693 549 p_igetl(&bufsize, f);
12694
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if (bufsize < 0 || bufsize > 1024)
12695 return qe_invalid;
12696 549 buf = new char[bufsize+1];
12697 549 pfread(buf, bufsize, f);
12698 549 buf[bufsize]=0;
12699
12700 //fix this too
12701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
549 if(id <NUMSCRIPTSDMAP-1)
12702 549 dmapmap[id].scriptname = buf;
12703
12704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
549 delete[] buf;
12705 549 }
12706 //screen
12707 word numscreenbindings;
12708 210 p_igetw(&numscreenbindings, f);
12709
12710
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 210 times.
651 for(int32_t i=0; i<numscreenbindings; i++)
12711 {
12712 word id;
12713 441 p_igetw(&id, f);
12714 441 p_igetl(&bufsize, f);
12715
2/4
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
441 if (bufsize < 0 || bufsize > 1024)
12716 return qe_invalid;
12717 441 buf = new char[bufsize+1];
12718 441 pfread(buf, bufsize, f);
12719 441 buf[bufsize]=0;
12720
12721 //fix this too
12722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 if(id <NUMSCRIPTSDMAP-1)
12723 441 screenmap[id].scriptname = buf;
12724
12725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 delete[] buf;
12726 441 }
12727 210 }
12728
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version > 11)
12729 {
12730 word numspritebindings;
12731 210 p_igetw(&numspritebindings, f);
12732
12733
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 210 times.
281 for(int32_t i=0; i<numspritebindings; i++)
12734 {
12735 word id;
12736 71 p_igetw(&id, f);
12737 71 p_igetl(&bufsize, f);
12738
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
71 if (bufsize < 0 || bufsize > 1024)
12739 return qe_invalid;
12740 71 buf = new char[bufsize+1];
12741 71 pfread(buf, bufsize, f);
12742 71 buf[bufsize]=0;
12743
12744 //fix this too
12745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(id <NUMSCRIPTSDMAP-1)
12746 71 itemspritemap[id].scriptname = buf;
12747
12748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 delete[] buf;
12749 71 }
12750 210 }
12751
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version >= 15)
12752 {
12753 word numcombobindings;
12754 210 p_igetw(&numcombobindings, f);
12755
12756
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 210 times.
427 for(int32_t i=0; i<numcombobindings; i++)
12757 {
12758 word id;
12759 217 p_igetw(&id, f);
12760 217 p_igetl(&bufsize, f);
12761
2/4
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
217 if (bufsize < 0 || bufsize > 1024)
12762 return qe_invalid;
12763 217 buf = new char[bufsize+1];
12764 217 pfread(buf, bufsize, f);
12765 217 buf[bufsize]=0;
12766
12767 //fix this too
12768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(id <NUMSCRIPTSCOMBODATA-1)
12769 217 comboscriptmap[id].scriptname = buf;
12770
12771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 delete[] buf;
12772 217 }
12773 210 }
12774
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if(s_version > 19)
12775 {
12776 word numgenericbindings;
12777 210 p_igetw(&numgenericbindings, f);
12778
12779
2/2
✓ Branch 0 taken 2432 times.
✓ Branch 1 taken 210 times.
2642 for(int32_t i=0; i<numgenericbindings; i++)
12780 {
12781 word id;
12782 2432 p_igetw(&id, f);
12783 2432 p_igetl(&bufsize, f);
12784
2/4
✓ Branch 0 taken 2432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2432 times.
✗ Branch 3 not taken.
2432 if (bufsize < 0 || bufsize > 1024)
12785 return qe_invalid;
12786 2432 buf = new char[bufsize+1];
12787 2432 pfread(buf, bufsize, f);
12788 2432 buf[bufsize]=0;
12789
12790 //fix this too
12791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
2432 if(id <NUMSCRIPTSGENERIC-1)
12792 2432 genericmap[id].scriptname = buf;
12793
12794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
2432 delete[] buf;
12795 2432 }
12796 210 }
12797
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 193 times.
410 if(s_version > 21)
12798 {
12799 word numsubscreenbindings;
12800 193 p_igetw(&numsubscreenbindings, f);
12801
12802
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 193 times.
211 for(int32_t i=0; i<numsubscreenbindings; i++)
12803 {
12804 word id;
12805 18 p_igetw(&id, f);
12806 18 p_igetl(&bufsize, f);
12807
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if (bufsize < 0 || bufsize > 1024)
12808 return qe_invalid;
12809 18 buf = new char[bufsize+1];
12810 18 pfread(buf, bufsize, f);
12811 18 buf[bufsize]=0;
12812
12813 //fix this too
12814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(id <NUMSCRIPTSSUBSCREEN-1)
12815 18 subscreenmap[id].scriptname = buf;
12816
12817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
12818 18 }
12819 193 }
12820 410 }
12821
12822 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12823 // This is only updated when the scripts have been recompiled.
12824 // They should all match each other.
12825 410 std::optional<word> zscript_version;
12826
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 210 times.
410 if (s_version >= 16)
12827 {
12828
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 9604 times.
9812 for (auto script : read_scripts)
12829 {
12830
2/2
✓ Branch 0 taken 9602 times.
✓ Branch 1 taken 2 times.
9604 if (script->meta.ffscript_v == 0)
12831 {
12832 // These scripts were saved in a version prior to this field being set.
12833 // See https://discord.com/channels/876899628556091432/1368485306394738718
12834 2 zscript_version = 16;
12835 2 break;
12836 }
12837
1/2
✓ Branch 0 taken 9602 times.
✗ Branch 1 not taken.
9602 if (script->meta.ffscript_v > s_version)
12838 break;
12839
12840
2/2
✓ Branch 0 taken 9412 times.
✓ Branch 1 taken 190 times.
9602 if (!zscript_version.has_value())
12841 {
12842 190 zscript_version = script->meta.ffscript_v;
12843 190 continue;
12844 }
12845
12846
1/2
✓ Branch 0 taken 9412 times.
✗ Branch 1 not taken.
9412 if (zscript_version.value() != script->meta.ffscript_v)
12847 {
12848 zscript_version.reset();
12849 break;
12850 }
12851 }
12852
12853
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 18 times.
210 if (!zscript_version.has_value())
12854 18 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12855 210 }
12856 410 setZScriptVersion(zscript_version.value_or(s_version));
12857 410 read_scripts.clear();
12858
12859 410 return 0;
12860 410 }
12861
12862 void(*reset_scripts_hook)();
12863
12864 492 void reset_scripts()
12865 {
12866 // We can't modify the script data while jit threads are possibly compiling them.
12867
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 481 times.
492 if (reset_scripts_hook)
12868 481 reset_scripts_hook();
12869
12870
2/2
✓ Branch 0 taken 251904 times.
✓ Branch 1 taken 492 times.
252396 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12871 {
12872
1/2
✓ Branch 0 taken 251904 times.
✗ Branch 1 not taken.
251904 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12873 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12874 251904 }
12875
12876
2/2
✓ Branch 0 taken 251904 times.
✓ Branch 1 taken 492 times.
252396 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12877 {
12878
1/2
✓ Branch 0 taken 251904 times.
✗ Branch 1 not taken.
251904 if (ffscripts[i])
12879 251904 ffscripts[i]->disable();
12880 else
12881 ffscripts[i] = new script_data(ScriptType::FFC, i);
12882 251904 }
12883
12884
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12885 {
12886
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (itemscripts[i])
12887 125952 itemscripts[i]->disable();
12888 else
12889 itemscripts[i] = new script_data(ScriptType::Item, i);
12890 125952 }
12891
12892
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12893 {
12894
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (guyscripts[i])
12895 125952 guyscripts[i]->disable();
12896 else
12897 guyscripts[i] = new script_data(ScriptType::NPC, i);
12898 125952 }
12899
12900
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12901 {
12902
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (screenscripts[i])
12903 125952 screenscripts[i]->disable();
12904 else
12905 screenscripts[i] = new script_data(ScriptType::Screen, i);
12906 125952 }
12907
12908
2/2
✓ Branch 0 taken 3936 times.
✓ Branch 1 taken 492 times.
4428 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12909 {
12910
1/2
✓ Branch 0 taken 3936 times.
✗ Branch 1 not taken.
3936 if (globalscripts[i])
12911 3936 globalscripts[i]->disable();
12912 else
12913 globalscripts[i] = new script_data(ScriptType::Global, i);
12914 3936 }
12915
12916
2/2
✓ Branch 0 taken 2460 times.
✓ Branch 1 taken 492 times.
2952 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12917 {
12918
1/2
✓ Branch 0 taken 2460 times.
✗ Branch 1 not taken.
2460 if (playerscripts[i])
12919 2460 playerscripts[i]->disable();
12920 else
12921 playerscripts[i] = new script_data(ScriptType::Hero, i);
12922 2460 }
12923
12924
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12925 {
12926
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (lwpnscripts[i])
12927 125952 lwpnscripts[i]->disable();
12928 else
12929 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12930 125952 }
12931
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12932 {
12933
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (ewpnscripts[i])
12934 125952 ewpnscripts[i]->disable();
12935 else
12936 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12937 125952 }
12938
12939
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12940 {
12941
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (dmapscripts[i])
12942 125952 dmapscripts[i]->disable();
12943 else
12944 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12945 125952 }
12946
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 492 times.
126444 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12947 {
12948
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (itemspritescripts[i])
12949 125952 itemspritescripts[i]->disable();
12950 else
12951 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12952 125952 }
12953
2/2
✓ Branch 0 taken 251904 times.
✓ Branch 1 taken 492 times.
252396 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12954 {
12955
1/2
✓ Branch 0 taken 251904 times.
✗ Branch 1 not taken.
251904 if (comboscripts[i])
12956 251904 comboscripts[i]->disable();
12957 else
12958 comboscripts[i] = new script_data(ScriptType::Combo, i);
12959 251904 }
12960
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 125952 times.
126444 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12961 {
12962
1/2
✓ Branch 0 taken 125952 times.
✗ Branch 1 not taken.
125952 if (subscreenscripts[i])
12963 125952 subscreenscripts[i]->disable();
12964 else
12965 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12966 125952 }
12967 492 }
12968
12969 // 3.0+ calls this.
12970 144 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12971 {
12972 int32_t num_commands;
12973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&num_commands,f))
12974 return qe_invalid;
12975 #ifdef ZC_FUZZ
12976 const int32_t command_limit = 300000;
12977 #else
12978 144 const int32_t command_limit = 25000000;
12979 #endif
12980
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if (num_commands < 0 || num_commands > command_limit)
12981 return qe_invalid;
12982
12983 144 std::vector<ffscript> zasm;
12984
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 zasm.reserve(num_commands);
12985
2/2
✓ Branch 0 taken 5856557 times.
✓ Branch 1 taken 144 times.
5856701 for(int32_t j=0; j<num_commands; j++)
12986 {
12987
1/2
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
5856557 ffscript temp_script;
12988
2/4
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5856557 times.
✗ Branch 3 not taken.
5856557 if(!p_igetw(&(temp_script.command),f))
12989 return qe_invalid;
12990
12991
2/4
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5856557 times.
✗ Branch 3 not taken.
5856557 if(!p_igetl(&(temp_script.arg1),f))
12992 return qe_invalid;
12993
12994
2/4
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5856557 times.
✗ Branch 3 not taken.
5856557 if(!p_igetl(&(temp_script.arg2),f))
12995 return qe_invalid;
12996
12997
2/4
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5856557 times.
✗ Branch 3 not taken.
5856557 if(!p_igetl(&(temp_script.arg3),f))
12998 return qe_invalid;
12999
13000 5856557 uint32_t sz = 0;
13001
2/4
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5856557 times.
✗ Branch 3 not taken.
5856557 if(!p_igetl(&sz,f))
13002 return qe_invalid;
13003
2/2
✓ Branch 0 taken 44877 times.
✓ Branch 1 taken 5811680 times.
5856557 if(sz) //string found
13004 {
13005
1/2
✓ Branch 0 taken 44877 times.
✗ Branch 1 not taken.
44877 temp_script.strptr = new std::string();
13006 char dummy;
13007
2/2
✓ Branch 0 taken 861893 times.
✓ Branch 1 taken 44877 times.
906770 for(size_t q = 0; q < sz; ++q)
13008 {
13009
2/4
✓ Branch 0 taken 861893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 861893 times.
✗ Branch 3 not taken.
861893 if(!p_getc(&dummy,f))
13010 return qe_invalid;
13011
1/2
✓ Branch 0 taken 861893 times.
✗ Branch 1 not taken.
861893 temp_script.strptr->push_back(dummy);
13012 861893 }
13013 44877 }
13014
2/4
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5856557 times.
✗ Branch 3 not taken.
5856557 if(!p_igetl(&sz,f))
13015 return qe_invalid;
13016
2/2
✓ Branch 0 taken 7995 times.
✓ Branch 1 taken 5848562 times.
5856557 if(sz) //vector found
13017 {
13018
1/2
✓ Branch 0 taken 7995 times.
✗ Branch 1 not taken.
7995 temp_script.vecptr = new std::vector<int32_t>();
13019 int32_t dummy;
13020
2/2
✓ Branch 0 taken 52735 times.
✓ Branch 1 taken 7995 times.
60730 for(size_t q = 0; q < sz; ++q)
13021 {
13022
2/4
✓ Branch 0 taken 52735 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52735 times.
✗ Branch 3 not taken.
52735 if(!p_igetl(&dummy,f))
13023 return qe_invalid;
13024
1/2
✓ Branch 0 taken 52735 times.
✗ Branch 1 not taken.
52735 temp_script.vecptr->push_back(dummy);
13025 52735 }
13026 7995 }
13027
1/2
✓ Branch 0 taken 5856557 times.
✗ Branch 1 not taken.
5856557 zasm.emplace_back(std::move(temp_script));
13028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5856557 times.
5856557 }
13029
13030
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 assert(zasm_scripts.empty());
13031 144 zasm_script_id id = zasm_scripts.size();
13032
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
13033
13034 144 return 0;
13035 144 }
13036
13037 1113378 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13038 {
13039 ASSERT(script);
13040
2/2
✓ Branch 0 taken 558546 times.
✓ Branch 1 taken 554832 times.
1113378 if(s_version < 27)
13041 558546 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
13042
13043 char exists;
13044
1/2
✓ Branch 0 taken 554832 times.
✗ Branch 1 not taken.
554832 if (!p_getc(&exists, f))
13045 return qe_invalid;
13046
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 548272 times.
554832 if (!exists)
13047 {
13048 548272 script->disable();
13049 548272 return 0;
13050 }
13051
13052 //Read meta
13053 {
13054 6560 zasm_meta temp_meta;
13055
13056
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.zasm_v),f))
13057 return qe_invalid;
13058
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.meta_v),f))
13059 return qe_invalid;
13060
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.ffscript_v),f))
13061 return qe_invalid;
13062
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_getc(&(temp_meta.script_type),f))
13063 return qe_invalid;
13064
13065
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 6560 times.
59040 for(int32_t q = 0; q < 8; ++q)
13066 {
13067
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getcstr(&temp_meta.run_idens[q],f))
13068 return qe_invalid;
13069 52480 }
13070
13071
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 52480 times.
59040 for(int32_t q = 0; q < 8; ++q)
13072
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getc(&(temp_meta.run_types[q]),f))
13073 return qe_invalid;
13074
13075
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_getc(&(temp_meta.flags),f))
13076 return qe_invalid;
13077
13078
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.compiler_v1),f))
13079 return qe_invalid;
13080
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.compiler_v2),f))
13081 return qe_invalid;
13082
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.compiler_v3),f))
13083 return qe_invalid;
13084
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_igetw(&(temp_meta.compiler_v4),f))
13085 return qe_invalid;
13086
13087
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_getcstr(&temp_meta.script_name,f))
13088 return qe_invalid;
13089
2/4
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
✗ Branch 3 not taken.
6560 if(!p_getcstr(&temp_meta.author,f))
13090 return qe_invalid;
13091 6560 auto num_meta_attrib = 10;
13092
2/2
✓ Branch 0 taken 65600 times.
✓ Branch 1 taken 6560 times.
72160 for(auto q = 0; q < num_meta_attrib; ++q)
13093 {
13094
2/4
✓ Branch 0 taken 65600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65600 times.
✗ Branch 3 not taken.
65600 if(!p_getcstr(&temp_meta.attributes[q],f))
13095 return qe_invalid;
13096
2/4
✓ Branch 0 taken 65600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65600 times.
✗ Branch 3 not taken.
65600 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13097 return qe_invalid;
13098 65600 }
13099
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 6560 times.
59040 for(auto q = 0; q < 8; ++q)
13100 {
13101
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getcstr(&temp_meta.attribytes[q],f))
13102 return qe_invalid;
13103
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13104 return qe_invalid;
13105 52480 }
13106
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 6560 times.
59040 for(auto q = 0; q < 8; ++q)
13107 {
13108
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13109 return qe_invalid;
13110
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13111 return qe_invalid;
13112 52480 }
13113
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 6560 times.
111520 for(auto q = 0; q < 16; ++q)
13114 {
13115
2/4
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104960 times.
✗ Branch 3 not taken.
104960 if(!p_getcstr(&temp_meta.usrflags[q],f))
13116 return qe_invalid;
13117
2/4
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104960 times.
✗ Branch 3 not taken.
104960 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13118 return qe_invalid;
13119 104960 }
13120
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 6560 times.
59040 for(auto q = 0; q < 8; ++q)
13121 {
13122
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getcstr(&temp_meta.initd[q],f))
13123 return qe_invalid;
13124
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getwstr(&temp_meta.initd_help[q],f))
13125 return qe_invalid;
13126 52480 }
13127
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 52480 times.
59040 for(auto q = 0; q < 8; ++q)
13128 {
13129
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(!p_getc(&temp_meta.initd_type[q],f))
13130 return qe_invalid;
13131 52480 }
13132
13133
1/2
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
6560 script->meta = temp_meta;
13134
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6560 times.
6560 }
13135
1/2
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
6560 if(!p_igetl(&script->pc, f))
13136 return qe_invalid;
13137
1/2
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
6560 if(!p_igetl(&script->end_pc, f))
13138 return qe_invalid;
13139
13140
1/2
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
6560 if (script == &fake_script_data)
13141 return 0;
13142
13143
1/2
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
6560 assert(zasm_scripts.size() == 1);
13144 6560 auto& zs = zasm_scripts[0];
13145 6560 script->zasm_script = zs;
13146
13147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6560 times.
6560 if (script->valid())
13148 {
13149 6560 zs->script_datas.push_back(script);
13150 6560 read_scripts.push_back(script);
13151 6560 }
13152
13153 6560 return 0;
13154 1113378 }
13155
13156 558546 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13157 {
13158 558546 char b33[34] = {0};
13159 558546 b33[33] = 0;
13160 558546 int32_t num_commands=1000;
13161
13162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558546 times.
558546 if(s_version>=2)
13163 {
13164
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 if(!p_igetl(&num_commands,f))
13165 {
13166 return qe_invalid;
13167 }
13168 558546 }
13169
13170 #ifdef ZC_FUZZ
13171 const int32_t command_limit = 300000;
13172 #else
13173 558546 const int32_t command_limit = 10000000;
13174 #endif
13175
2/4
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 558546 times.
558546 if (num_commands < 0 || num_commands > command_limit)
13176 {
13177 return qe_invalid;
13178 }
13179
13180 558546 std::vector<ffscript> zasm;
13181
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 zasm.reserve(num_commands);
13182
13183
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 308600 times.
558546 if(s_version >= 16)
13184 {
13185
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13186
13187
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13188 {
13189 return qe_invalid;
13190 }
13191
13192
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13193 {
13194 return qe_invalid;
13195 }
13196
13197
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13198 {
13199 return qe_invalid;
13200 }
13201
13202
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13203 {
13204 return qe_invalid;
13205 }
13206
13207
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13208 {
13209
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13210 {
13211
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13212 {
13213
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13214 {
13215 return qe_invalid;
13216 }
13217 4748040 }
13218
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13219 143880 }
13220 else
13221 {
13222
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13223 {
13224 return qe_invalid;
13225 }
13226 }
13227 1999568 }
13228
13229
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13230 {
13231
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13232 {
13233 return qe_invalid;
13234 }
13235 1999568 }
13236
13237
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13238 {
13239 return qe_invalid;
13240 }
13241
13242
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13243 {
13244 return qe_invalid;
13245 }
13246
13247
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13248 {
13249 return qe_invalid;
13250 }
13251
13252
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13253 {
13254 return qe_invalid;
13255 }
13256
13257
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13258 {
13259 return qe_invalid;
13260 }
13261
13262
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13263 {
13264
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13265 {
13266
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13267 {
13268 return qe_invalid;
13269 }
13270 593505 }
13271
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13272
13273
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13274 {
13275
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13276 {
13277 return qe_invalid;
13278 }
13279 593505 }
13280
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13281 17985 }
13282
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13283 {
13284
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13285 return qe_invalid;
13286
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13287 return qe_invalid;
13288 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13289
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13290 {
13291
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13292 return qe_invalid;
13293
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13294 return qe_invalid;
13295 2319610 }
13296
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13297 {
13298
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13299 return qe_invalid;
13300
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13301 return qe_invalid;
13302 1855688 }
13303
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13304 {
13305
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13306 return qe_invalid;
13307
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13308 return qe_invalid;
13309 1855688 }
13310
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13311 {
13312
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13313 return qe_invalid;
13314
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13315 return qe_invalid;
13316 3711376 }
13317 231961 }
13318
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13319 {
13320
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13321 {
13322
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13323 return qe_invalid;
13324
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13325 return qe_invalid;
13326 1855688 }
13327
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13328 {
13329
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13330 return qe_invalid;
13331 1855688 }
13332 231961 }
13333 else
13334 {
13335
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13336 {
13337
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13338 143880 }
13339 }
13340
13341
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13342
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 308600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308600 times.
✗ Branch 5 not taken.
558546 } else script->meta = {};
13343
13344
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 106040107 times.
106114781 for(int32_t j=0; j<num_commands; j++)
13345 {
13346
1/2
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
106040107 auto& sc = zasm.emplace_back();
13347
2/4
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106040107 times.
✗ Branch 3 not taken.
106040107 if(!p_igetw(&sc.command,f))
13348 {
13349 return qe_invalid;
13350 }
13351
13352
2/2
✓ Branch 0 taken 105556235 times.
✓ Branch 1 taken 483872 times.
106040107 if(sc.command == 0xFFFF)
13353 483872 break;
13354 else
13355 {
13356
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg1,f))
13357 {
13358 return qe_invalid;
13359 }
13360
13361
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg2,f))
13362 {
13363 return qe_invalid;
13364 }
13365
13366
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 104508488 times.
105556235 if(s_version >= 24)
13367
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13368 return qe_invalid;
13369
13370
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 97334198 times.
105556235 if(s_version >= 21)
13371 {
13372 8222037 uint32_t sz = 0;
13373
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13374 {
13375 return qe_invalid;
13376 }
13377
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13378 {
13379
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13380 char dummy;
13381
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13382 {
13383
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13384 {
13385 return qe_invalid;
13386 }
13387
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13388 1165008 }
13389 19400 }
13390
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13391 {
13392 return qe_invalid;
13393 }
13394
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13395 {
13396
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13397 int32_t dummy;
13398
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13399 {
13400
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13401 {
13402 return qe_invalid;
13403 }
13404
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13405 11526 }
13406 933 }
13407 8222037 }
13408 }
13409 105556235 }
13410
13411
2/2
✓ Branch 0 taken 490450 times.
✓ Branch 1 taken 68096 times.
558546 if (script == &fake_script_data)
13412 68096 return 0;
13413
13414 // If the first command is unknown, invalidate the whole thing.
13415 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13416
5/6
✓ Branch 0 taken 421152 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 409175 times.
✓ Branch 3 taken 11977 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 409175 times.
490450 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13417 {
13418 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13419 zasm.clear();
13420 }
13421
13422 490450 zasm_script_id id = zasm_scripts.size();
13423
3/6
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 490450 times.
✗ Branch 5 not taken.
490450 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13424 490450 script->zasm_script = zs;
13425 490450 script->pc = 0;
13426 490450 script->end_pc = zs->size;
13427
3/4
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 478473 times.
490450 if (script->valid())
13428 {
13429
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 zs->script_datas.push_back(script);
13430
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 read_scripts.push_back(script);
13431 11977 }
13432
13433 490450 return 0;
13434 558546 }
13435
13436 extern SAMPLE customsfxdata[WAV_COUNT];
13437 extern uint8_t customsfxflag[WAV_COUNT>>3];
13438 extern int32_t sfxdat;
13439 extern DATAFILE *sfxdata;
13440 const char *old_sfx_string[Z35] =
13441 {
13442 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13443 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13444 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13445 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13446 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13447 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13448 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13449 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13450 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13451 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13452 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13453 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13454 };
13455 char *sfx_string[WAV_COUNT];
13456
13457 410 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13458 {
13459 //these are here to bypass compiler warnings about unused arguments
13460 410 Header=Header;
13461
13462 int32_t dummy;
13463 410 word s_version=0;
13464 //int32_t ret;
13465 410 SAMPLE temp_sample = {};
13466 410 temp_sample.loop_start=0;
13467 410 temp_sample.loop_end=0;
13468 410 temp_sample.param=0;
13469
13470 //section version info
13471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(!p_igetw(&s_version,f))
13472 {
13473 return qe_invalid;
13474 }
13475
13476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_SFX)
13477 return qe_version;
13478
13479 410 FFCore.quest_format[vSFX] = s_version;
13480
13481
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
13482 {
13483 return qe_invalid;
13484 }
13485
13486 //section size
13487
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&dummy,f))
13488 {
13489 return qe_invalid;
13490 }
13491
13492 /* HIGHLY UNORTHODOX UPDATING THING, by L
13493 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13494 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13495 * changing from 1 to 2.
13496 */
13497
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(s_version < 2)
13498 set_qr(qr_GOTOLESSNOTEQUAL,1);
13499
13500 /* End highly unorthodox updating thing */
13501
13502 410 int32_t wavcount = WAV_COUNT;
13503
13504
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(s_version < 6)
13505 wavcount = 128;
13506
13507 uint8_t tempflag[WAV_COUNT>>3];
13508
13509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(s_version < 4)
13510 {
13511 memset(tempflag, 0xFF, WAV_COUNT>>3);
13512 }
13513 else
13514 {
13515
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(s_version < 6)
13516 memset(tempflag, 0, WAV_COUNT>>3);
13517
13518
2/2
✓ Branch 0 taken 13120 times.
✓ Branch 1 taken 410 times.
13530 for(int32_t i=0; i<(wavcount>>3); i++)
13519 {
13520 13120 p_getc(&tempflag[i], f);
13521 13120 }
13522
13523 }
13524
13525
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(s_version>4)
13526 {
13527
2/2
✓ Branch 0 taken 104550 times.
✓ Branch 1 taken 410 times.
104960 for(int32_t i=1; i<WAV_COUNT; i++)
13528 {
13529 104550 sprintf(sfx_string[i],"s%03d",i);
13530
13531
2/2
✓ Branch 0 taken 79950 times.
✓ Branch 1 taken 24600 times.
104550 if((i<Z35))
13532 24600 strcpy(sfx_string[i], old_sfx_string[i-1]);
13533
13534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104550 times.
104550 if(i>=wavcount)
13535 continue;
13536
2/2
✓ Branch 0 taken 22776 times.
✓ Branch 1 taken 81774 times.
104550 if(get_bit(tempflag, i-1))
13537 {
13538 char tempname[36];
13539
13540
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!pfread(tempname, 36, f))
13541 {
13542 return qe_invalid;
13543 }
13544
13545 22776 sfx_string[i][0] = '\0';
13546 22776 strncat(sfx_string[i], tempname, 36 - 1);
13547 22776 }
13548 else
13549 {
13550 81774 sprintf(sfx_string[i],"s%03d",i);
13551
13552
2/2
✓ Branch 0 taken 72084 times.
✓ Branch 1 taken 9690 times.
81774 if(i<Z35)
13553 9690 strcpy(sfx_string[i], old_sfx_string[i-1]);
13554 81774 sfx_string[i][35] = 0; //Force NULL Termination
13555 }
13556 104550 }
13557 410 }
13558 else
13559 {
13560 for(int32_t i=1; i<WAV_COUNT; i++)
13561 {
13562 sprintf(sfx_string[i],"s%03d",i);
13563
13564 if(i<Z35)
13565 strcpy(sfx_string[i], old_sfx_string[i-1]);
13566 }
13567 }
13568
13569 //finally... section data
13570
2/2
✓ Branch 0 taken 104550 times.
✓ Branch 1 taken 410 times.
104960 for(int32_t i=1; i<wavcount; i++)
13571 {
13572
2/2
✓ Branch 0 taken 22776 times.
✓ Branch 1 taken 81774 times.
104550 if(get_bit(tempflag, i-1))
13573 {
13574
13575
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&dummy,f))
13576 {
13577 return qe_invalid;
13578 }
13579
13580 22776 (temp_sample.bits) = dummy;
13581
13582
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&dummy,f))
13583 {
13584 return qe_invalid;
13585 }
13586
13587 22776 (temp_sample.stereo) = dummy;
13588
13589
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&dummy,f))
13590 {
13591 return qe_invalid;
13592 }
13593
13594 22776 (temp_sample.freq) = dummy;
13595
13596
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&dummy,f))
13597 {
13598 return qe_invalid;
13599 }
13600
13601 22776 (temp_sample.priority) = dummy;
13602
13603
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&(temp_sample.len),f))
13604 {
13605 return qe_invalid;
13606 }
13607
13608
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&(temp_sample.loop_start),f))
13609 {
13610 return qe_invalid;
13611 }
13612
13613
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&(temp_sample.loop_end),f))
13614 {
13615 return qe_invalid;
13616 }
13617
13618
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(!p_igetl(&(temp_sample.param),f))
13619 {
13620 return qe_invalid;
13621 }
13622
13623 22776 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13624 #ifdef ZC_FUZZ
13625 const int32_t sfx_limit = 100000;
13626 if (len < 0 || len > sfx_limit)
13627 {
13628 return qe_invalid;
13629 }
13630 #endif
13631 22776 temp_sample.data = calloc(len,1);
13632
13633
1/2
✓ Branch 0 taken 22776 times.
✗ Branch 1 not taken.
22776 if(s_version < 3)
13634 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13635
13636 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22776 times.
22776 if(s_version < 2)
13638 {
13639 if(!pfread(temp_sample.data, len,f))
13640 {
13641 return qe_invalid;
13642 }
13643 }
13644 else
13645 {
13646 //re-endianfy the data
13647 22776 int32_t wordstoread = len / sizeof(word);
13648
13649
2/2
✓ Branch 0 taken 659181870 times.
✓ Branch 1 taken 22776 times.
659204646 for(int32_t j=0; j<wordstoread; j++)
13650 {
13651 word temp;
13652
13653
1/2
✓ Branch 0 taken 659181870 times.
✗ Branch 1 not taken.
659181870 if(!p_igetw(&temp, f))
13654 {
13655 return qe_invalid;
13656 }
13657
13658 659181870 ((word *)temp_sample.data)[j] = temp;
13659 659181870 }
13660 }
13661 22776 }
13662
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 72084 times.
81774 else if(i < Z35)
13663 {
13664 9690 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13665 9690 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13666 9690 set_bit(tempflag, i-1, 1);
13667 9690 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13668 9690 temp_sample.data = calloc(len,1);
13669 9690 memcpy(temp_sample.data, datsamp->data, len);
13670 9690 }
13671 72084 else continue;
13672
13673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32466 times.
32466 if(customsfxdata[i].data!=NULL)
13674 {
13675 // delete [] customsfxdata[i].data;
13676 32466 free(customsfxdata[i].data);
13677 32466 }
13678
13679 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13680 32466 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13681 32466 customsfxdata[i].data = calloc(len2,1);
13682 32466 customsfxdata[i].bits = temp_sample.bits;
13683 32466 customsfxdata[i].stereo = temp_sample.stereo;
13684 32466 customsfxdata[i].freq = temp_sample.freq;
13685 32466 customsfxdata[i].priority = temp_sample.priority;
13686 32466 customsfxdata[i].len = temp_sample.len;
13687 32466 customsfxdata[i].loop_start = temp_sample.loop_start;
13688 32466 customsfxdata[i].loop_end = temp_sample.loop_end;
13689 32466 customsfxdata[i].param = temp_sample.param;
13690 32466 int32_t cpylen = len2;
13691
13692
1/2
✓ Branch 0 taken 32466 times.
✗ Branch 1 not taken.
32466 if(s_version<3)
13693 {
13694 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13695 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13696 }
13697
13698 32466 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13699
13700 32466 free(temp_sample.data);
13701 32466 }
13702
13703 410 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13704
13705 410 sfxdat=0;
13706 410 return 0;
13707 410 }
13708
13709 492 void setupsfx()
13710 {
13711
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=1; i<WAV_COUNT; i++)
13712 {
13713 125460 sprintf(sfx_string[i],"s%03d",i);
13714
13715
2/2
✓ Branch 0 taken 95940 times.
✓ Branch 1 taken 29520 times.
125460 if(i<Z35)
13716 {
13717 29520 strcpy(sfx_string[i], old_sfx_string[i-1]);
13718 29520 }
13719
13720 125460 memset(customsfxflag, 0, WAV_COUNT>>3);
13721
13722 125460 int32_t j=i;
13723
13724
2/2
✓ Branch 0 taken 30012 times.
✓ Branch 1 taken 95448 times.
125460 if(i>Z35)
13725 {
13726 95448 i=Z35;
13727 95448 }
13728
13729 125460 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13730
13731
2/2
✓ Branch 0 taken 96900 times.
✓ Branch 1 taken 28560 times.
125460 if(customsfxdata[j].data!=NULL)
13732 {
13733 // delete [] customsfxdata[j].data;
13734 28560 free(customsfxdata[j].data);
13735 28560 }
13736
13737 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13738 125460 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13739 125460 customsfxdata[j].bits = temp_sample->bits;
13740 125460 customsfxdata[j].stereo = temp_sample->stereo;
13741 125460 customsfxdata[j].freq = temp_sample->freq;
13742 125460 customsfxdata[j].priority = temp_sample->priority;
13743 125460 customsfxdata[j].len = temp_sample->len;
13744 125460 customsfxdata[j].loop_start = temp_sample->loop_start;
13745 125460 customsfxdata[j].loop_end = temp_sample->loop_end;
13746 125460 customsfxdata[j].param = temp_sample->param;
13747 125460 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13748 125460 i=j;
13749 125460 }
13750 492 }
13751
13752 extern char *guy_string[eMAXGUYS];
13753 extern const char *old_guy_string[OLDMAXGUYS];
13754
13755 492 int32_t readguys(PACKFILE *f, zquestheader *Header)
13756 {
13757
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
492 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if (should_skip) return 0;
13759
13760 dword dummy;
13761 word guy_cversion;
13762 492 word guyversion=0;
13763
13764
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 469 times.
492 if(Header->zelda_version >= 0x193)
13765 {
13766 //section version info
13767
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&guyversion,f))
13768 {
13769 return qe_invalid;
13770 }
13771
13772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (guyversion > V_GUYS)
13773 return qe_version;
13774
13775 469 FFCore.quest_format[vGuys] = guyversion;
13776
13777 // Note: this is the only instance where "cversion" is ever used.
13778
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&guy_cversion,f))
13779 {
13780 return qe_invalid;
13781 }
13782
13783 //section size
13784
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy,f))
13785 {
13786 return qe_invalid;
13787 }
13788 469 }
13789
13790
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
492 if(guyversion > 3)
13791 {
13792
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 410 times.
210330 for(int32_t i=0; i<MAXGUYS; i++)
13793 {
13794 char tempname[64];
13795
13796 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13797 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209920 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13799 {
13800 memset(tempname, 0, sizeof(char)*64);
13801 sprintf(tempname, "e%03d", i);
13802 strcpy(guy_string[i], tempname);
13803
13804 continue;
13805 }
13806
13807
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!pfread(tempname, 64, f))
13808 {
13809 return qe_invalid;
13810 }
13811
13812 // Don't retain names of uneditable enemy entries!
13813 // for version upgrade to 2.5
13814
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209920 if(guyversion < 23 && i >= 177)
13815 {
13816 // some of the older builds have names such as 'zz123',
13817 // (this order gets messed up with some eXXX and some zzXXX)
13818 // so let's update to the newer naming convection. -Gleeok
13819 char tmpbuf[64];
13820 memset(tmpbuf, 0, sizeof(char)*64);
13821 sprintf(tmpbuf, "zz%03d", i);
13822
13823 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13824 {
13825 memset(tempname, 0, sizeof(char)*64);
13826 sprintf(tempname, "e%03d", i);
13827 }
13828 }
13829
13830
6/6
✓ Branch 0 taken 72570 times.
✓ Branch 1 taken 137350 times.
✓ Branch 2 taken 68880 times.
✓ Branch 3 taken 3690 times.
✓ Branch 4 taken 60230 times.
✓ Branch 5 taken 8650 times.
209920 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13831 {
13832 201270 guy_string[i][0] = '\0';
13833 201270 strncat(guy_string[i], tempname, 64 - 1);
13834 201270 }
13835 else
13836 {
13837 8650 strcpy(guy_string[i],old_guy_string[i]);
13838 }
13839 209920 }
13840 410 }
13841 else
13842 {
13843
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13844 {
13845 41984 sprintf(guy_string[i],"zz%03d",i);
13846 41984 }
13847
13848
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13849 {
13850 14514 strcpy(guy_string[i],old_guy_string[i]);
13851 14514 }
13852 }
13853
13854
13855 //finally... section data
13856 492 init_guys(guyversion); //using default data for now...
13857
13858 // Goriya guy fix
13859
3/6
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
492 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13860 {
13861
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13862 {
13863 60 guysbuf[gGORIYA].tile=130;
13864 60 guysbuf[gGORIYA].e_tile=130;
13865 60 }
13866 82 }
13867
13868
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
492 if(Header->zelda_version < 0x193)
13869 {
13870
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13871 {
13872 5 guysbuf[eDODONGO].cset=14;
13873 5 guysbuf[eDODONGO].bosspal=spDIG;
13874 5 }
13875 23 }
13876 // Not sure when this first changed, but it's necessary for 2.10, at least
13877 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13878 //2.10 Fixes
13879
3/6
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
492 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13880 {
13881 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13882 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13883 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13884 82 guysbuf[eCENT1].attributes[2] = 1;
13885 82 guysbuf[eCENT2].attributes[2] = 1;
13886 82 }
13887
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
492 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13888 {
13889 492 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13890 492 }
13891
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
492 if(Header->zelda_version <= 0x210)
13892 {
13893 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13894 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13895 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13896 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13897
13898 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13899 82 guysbuf[eBATROBE].attributes[3] = 1;
13900 //guysbuf[eSUMMONER].misc4 = 1;
13901 82 guysbuf[eWWIZ].attributes[3] = 1;
13902 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13903 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13904 82 }
13905
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 12 times.
492 if(Header->zelda_version == 0x190)
13906 {
13907 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13908 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13909 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13910 12 }
13911
13912 // The versions here may not be correct
13913 // zelda_version>=0x211 handled at guyversion<24
13914
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 474 times.
492 if(Header->zelda_version <= 0x190)
13915 {
13916 18 guysbuf[eCENT1].attributes[2] = 0;
13917 18 guysbuf[eCENT2].attributes[2] = 0;
13918 18 guysbuf[eMOLDORM].attributes[1] = 0;
13919 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13920 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13921 18 }
13922
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 64 times.
474 else if(Header->zelda_version <= 0x210)
13923 {
13924 64 guysbuf[eCENT1].attributes[2] = 1;
13925 64 guysbuf[eCENT2].attributes[2] = 1;
13926 64 guysbuf[eMOLDORM].attributes[1] = 0;
13927 64 }
13928
13929
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 82 times.
492 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13930 {
13931 82 guysbuf[eKEESE1].attributes[15] = 120;
13932 82 guysbuf[eKEESE2].attributes[15] = 120;
13933 82 guysbuf[eKEESE3].attributes[15] = 120;
13934 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13935 82 guysbuf[eKEESE1].attributes[16] = 16;
13936 82 guysbuf[eKEESE2].attributes[16] = 16;
13937 82 guysbuf[eKEESE3].attributes[16] = 16;
13938 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13939
13940 82 guysbuf[ePEAHAT].attributes[15] = 80;
13941 82 guysbuf[ePEAHAT].attributes[16] = 16;
13942
13943 82 guysbuf[eGHINI2].attributes[15] = 120;
13944 82 guysbuf[eGHINI2].attributes[16] = 10;
13945
13946
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13947 {
13948 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13949 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13950 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13951 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13952 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13953 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13954 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13955 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13956 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13957 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13958 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13959 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13960 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13961 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13962 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13963 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13964 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13965 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13966 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13967 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13968 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13969 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13970 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13971 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13972 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13973 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13974 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13975 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13976 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13977 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13978 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13979 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13980 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13981 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13982 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13983 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13984 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13985 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13986 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13987 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13988 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13989 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13990 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13991 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13992 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13993 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13994 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13995 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13996 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13997 66 }
13998 82 }
13999
14000
14001
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 410 times.
492 if(guyversion<=2)
14002 {
14003 82 return readherosprites2(f, guyversion==2?0:-1);
14004 }
14005
14006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(guyversion > 3)
14007 {
14008 410 guydata tempguy;
14009
14010
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 410 times.
210330 for(int32_t i=0; i<MAXGUYS; i++)
14011 {
14012
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 23) // May 2012 : 512 max enemies
14013 {
14014 if(i >= OLDBETAMAXGUYS)
14015 {
14016 guysbuf[i].clear();
14017 continue;
14018 }
14019 }
14020
14021 209920 tempguy.clear();
14022
14023 uint32_t flags1;
14024 uint32_t flags2;
14025
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetl(&(flags1),f))
14026 {
14027 return qe_invalid;
14028 }
14029
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetl(&(flags2),f))
14030 {
14031 return qe_invalid;
14032 }
14033 209920 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
14034
14035
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion >= 36 ) //expanded tiles
14036 {
14037
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.tile),f))
14038 {
14039 return qe_invalid;
14040 }
14041 107520 }
14042 else
14043 {
14044
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.tile),f))
14045 {
14046 return qe_invalid;
14047 }
14048 }
14049
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.width),f))
14050 {
14051 return qe_invalid;
14052 }
14053
14054
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.height),f))
14055 {
14056 return qe_invalid;
14057 }
14058
14059
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion >= 36 ) //expanded tiles
14060 {
14061
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.s_tile),f))
14062 {
14063 return qe_invalid;
14064 }
14065 107520 }
14066 else
14067 {
14068
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.s_tile),f))
14069 {
14070 return qe_invalid;
14071 }
14072 }
14073
14074
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.s_width),f))
14075 {
14076 return qe_invalid;
14077 }
14078
14079
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.s_height),f))
14080 {
14081 return qe_invalid;
14082 }
14083
14084
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion >= 36 ) //expanded tiles
14085 {
14086
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.e_tile),f))
14087 {
14088 return qe_invalid;
14089 }
14090 107520 }
14091 else
14092 {
14093
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.e_tile),f))
14094 {
14095 return qe_invalid;
14096 }
14097 }
14098
14099
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.e_width),f))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.e_height),f))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.hp),f))
14110 {
14111 return qe_invalid;
14112 }
14113
14114
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.type),f))
14115 {
14116 return qe_invalid;
14117 }
14118
14119
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
209920 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14120 {
14121 if(get_qr(qr_NEWENEMYTILES))
14122 {
14123 tempguy.s_tile=tempguy.e_tile+120;
14124 tempguy.s_width=tempguy.e_width;
14125 tempguy.s_height=tempguy.e_height;
14126 }
14127 else tempguy.s_tile=860;
14128 }
14129
14130
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.cset),f))
14131 {
14132 return qe_invalid;
14133 }
14134
14135
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.anim),f))
14136 {
14137 return qe_invalid;
14138 }
14139
14140
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.e_anim),f))
14141 {
14142 return qe_invalid;
14143 }
14144
14145
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.frate),f))
14146 {
14147 return qe_invalid;
14148 }
14149
14150
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.e_frate),f))
14151 {
14152 return qe_invalid;
14153 }
14154
14155
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 13) // April 2009
14156 {
14157 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14158 {
14159 tempguy.frate *= 2;
14160 tempguy.e_frate *= 2;
14161 }
14162 }
14163
14164
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 14) // May 1 2009
14165 {
14166 if(tempguy.anim==a2FRMSLOW)
14167 {
14168 tempguy.anim=a2FRM;
14169 tempguy.frate *= 2;
14170 }
14171
14172 if(tempguy.e_anim==a2FRMSLOW)
14173 {
14174 tempguy.e_anim=a2FRM;
14175 tempguy.e_frate *= 2;
14176 }
14177
14178 if(tempguy.anim==aFLIPSLOW)
14179 {
14180 tempguy.anim=aFLIP;
14181 tempguy.frate *= 2;
14182 }
14183
14184 if(tempguy.e_anim==aFLIPSLOW)
14185 {
14186 tempguy.e_anim=aFLIP;
14187 tempguy.e_frate *= 2;
14188 }
14189
14190 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14191
14192 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14193
14194 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14195 {
14196 tempguy.anim=a4FRM4DIR;
14197 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14198 }
14199
14200 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14201 {
14202 tempguy.e_anim=a4FRM4DIR;
14203 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14204 }
14205 }
14206
14207
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.dp),f))
14208 {
14209 return qe_invalid;
14210 }
14211
14212 //correction for guy fire
14213
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 6)
14214 {
14215 if(i == gFIRE)
14216 tempguy.dp = 2;
14217 }
14218
14219
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.wdp),f))
14220 {
14221 return qe_invalid;
14222 }
14223
14224
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.weapon),f))
14225 {
14226 return qe_invalid;
14227 }
14228
14229 //correction for bosses using triple, "rising" fireballs
14230
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 5)
14231 {
14232 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14233 i == eGOHMA3 || i == eGOHMA4)
14234 {
14235 if(tempguy.weapon == ewFireball)
14236 tempguy.weapon = ewFireball2;
14237 }
14238 }
14239
14240
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.rate),f))
14241 {
14242 return qe_invalid;
14243 }
14244
14245
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.hrate),f))
14246 {
14247 return qe_invalid;
14248 }
14249
14250
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.step),f))
14251 {
14252 return qe_invalid;
14253 }
14254
14255 // HIGHLY UNORTHODOX UPDATING THING, part 2
14256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209920 if(fixpolsvoice && tempguy.type==eePOLSV)
14257 {
14258 tempguy.step /= 2;
14259 }
14260
14261
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.homing),f))
14262 {
14263 return qe_invalid;
14264 }
14265
14266
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.grumble),f))
14267 {
14268 return qe_invalid;
14269 }
14270
14271
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.item_set),f))
14272 {
14273 return qe_invalid;
14274 }
14275
14276
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14277 {
14278
2/2
✓ Branch 0 taken 2099200 times.
✓ Branch 1 taken 209920 times.
2309120 for (int q = 0; q < 10; ++q)
14279 {
14280
1/2
✓ Branch 0 taken 2099200 times.
✗ Branch 1 not taken.
2099200 if (!p_igetl(&(tempguy.attributes[q]), f))
14281 {
14282 return qe_invalid;
14283 }
14284 2099200 }
14285 209920 }
14286 else
14287 {
14288 int16_t tempMisc;
14289
14290 for(int q=0;q<10;q++)
14291 {
14292 if (!p_igetw(&tempMisc, f))
14293 {
14294 return qe_invalid;
14295 }
14296 tempguy.attributes[q] = tempMisc;
14297 }
14298
14299 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14300 {
14301 if(tempguy.type == eeWIZZ && !(tempguy.attributes[0]))
14302 tempguy.attributes[4] = 74;
14303 }
14304
14305 }
14306
14307
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.bgsfx),f))
14308 {
14309 return qe_invalid;
14310 }
14311
14312
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.bosspal),f))
14313 {
14314 return qe_invalid;
14315 }
14316
14317
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetw(&(tempguy.extend),f))
14318 {
14319 return qe_invalid;
14320 }
14321
14322 //! Enemy Defences
14323
14324 //If a 2.50 quest, use only the 2.5 defences.
14325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
209920 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14326 {
14327
2/2
✓ Branch 0 taken 3988480 times.
✓ Branch 1 taken 209920 times.
4198400 for(int32_t j=0; j<edefLAST; j++)
14328 {
14329
1/2
✓ Branch 0 taken 3988480 times.
✗ Branch 1 not taken.
3988480 if(!p_getc(&(tempguy.defense[j]),f))
14330 {
14331 return qe_invalid;
14332 }
14333 3988480 }
14334 //then copy the generic script defence to all the new script defences
14335
14336 209920 }
14337
14338
14339
14340
14341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209920 times.
209920 if(guyversion >= 18)
14342 {
14343
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.hitsfx),f))
14344 {
14345 return qe_invalid;
14346 }
14347
14348
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&(tempguy.deadsfx),f))
14349 {
14350 return qe_invalid;
14351 }
14352 209920 }
14353
14354
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion >= 22)
14355 {
14356
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetl(&(tempguy.attributes[10]), f))
14357 {
14358 return qe_invalid;
14359 }
14360
14361
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_igetl(&(tempguy.attributes[11]),f))
14362 {
14363 return qe_invalid;
14364 }
14365 209920 }
14366 else if(guyversion >= 19)
14367 {
14368 int16_t tempMisc;
14369
14370 if(!p_igetw(&tempMisc,f))
14371 {
14372 return qe_invalid;
14373 }
14374
14375 tempguy.attributes[10] = tempMisc;
14376
14377 if(!p_igetw(&tempMisc,f))
14378 {
14379 return qe_invalid;
14380 }
14381
14382 tempguy.attributes[11] = tempMisc;
14383 }
14384
14385 //If a 2.54 or later quest, use all of the defences.
14386
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion > 24) // Add new guyversion conditional statement
14387 {
14388
2/2
✓ Branch 0 taken 2365440 times.
✓ Branch 1 taken 107520 times.
2472960 for(int32_t j=edefLAST; j<edefLAST255; j++)
14389 {
14390
1/2
✓ Branch 0 taken 2365440 times.
✗ Branch 1 not taken.
2365440 if(!p_getc(&(tempguy.defense[j]),f))
14391 {
14392 return qe_invalid;
14393 }
14394 2365440 }
14395 107520 }
14396
14397
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14398 {
14399
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14400 {
14401 1024000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14402 1024000 }
14403 102400 }
14404
14405 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14406
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion > 25)
14407 {
14408
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.txsz),f))
14409 {
14410 return qe_invalid;
14411 }
14412
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.tysz),f))
14413 {
14414 return qe_invalid;
14415 }
14416
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.hxsz),f))
14417 {
14418 return qe_invalid;
14419 }
14420
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.hysz),f))
14421 {
14422 return qe_invalid;
14423 }
14424
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.hzsz),f))
14425 {
14426 return qe_invalid;
14427 }
14428 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14429
14430 */
14431 107520 }
14432 //More Enemy Editor vars for 2.60
14433
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion > 26)
14434 {
14435
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.hxofs),f))
14436 {
14437 return qe_invalid;
14438 }
14439
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.hyofs),f))
14440 {
14441 return qe_invalid;
14442 }
14443
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.xofs),f))
14444 {
14445 return qe_invalid;
14446 }
14447
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.yofs),f))
14448 {
14449 return qe_invalid;
14450 }
14451
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.zofs),f))
14452 {
14453 return qe_invalid;
14454 }
14455 107520 }
14456
14457
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14458 {
14459 102400 tempguy.wpnsprite = 0;
14460 102400 }
14461
14462
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion > 27)
14463 {
14464
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.wpnsprite),f))
14465 {
14466 return qe_invalid;
14467 }
14468 107520 }
14469
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14470 {
14471 102400 tempguy.SIZEflags = 0;
14472 102400 }
14473
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion > 28)
14474 {
14475
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.SIZEflags),f))
14476 {
14477 return qe_invalid;
14478 }
14479
14480 107520 }
14481
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14482 {
14483 102400 tempguy.frozentile = 0;
14484 102400 tempguy.frozencset = 0;
14485 102400 tempguy.frozenclock = 0;
14486
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14487 102400 }
14488
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion >= 30)
14489 {
14490
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.frozentile),f))
14491 {
14492 return qe_invalid;
14493 }
14494
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.frozencset),f))
14495 {
14496 return qe_invalid;
14497 }
14498
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.frozenclock),f))
14499 {
14500 return qe_invalid;
14501 }
14502
2/2
✓ Branch 0 taken 1075200 times.
✓ Branch 1 taken 107520 times.
1182720 for ( int32_t q = 0; q < 10; q++ ) {
14503
1/2
✓ Branch 0 taken 1075200 times.
✗ Branch 1 not taken.
1075200 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14504 {
14505 return qe_invalid;
14506 }
14507 1075200 }
14508
14509 107520 }
14510
14511
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion >= 34)
14512 {
14513
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetw(&(tempguy.firesfx),f))
14514 {
14515 return qe_invalid;
14516 }
14517
2/2
✓ Branch 0 taken 1827840 times.
✓ Branch 1 taken 107520 times.
1935360 for(int q=15;q<32;++q)
14518 {
14519
1/2
✓ Branch 0 taken 1827840 times.
✗ Branch 1 not taken.
1827840 if(!p_igetl(&(tempguy.attributes[q]),f))
14520 {
14521 return qe_invalid;
14522 }
14523 1827840 }
14524
14525
2/2
✓ Branch 0 taken 3440640 times.
✓ Branch 1 taken 107520 times.
3548160 for ( int32_t q = 0; q < 32; q++ ) {
14526
1/2
✓ Branch 0 taken 3440640 times.
✗ Branch 1 not taken.
3440640 if(!p_igetl(&(tempguy.movement[q]),f))
14527 {
14528 return qe_invalid;
14529 }
14530 3440640 }
14531
2/2
✓ Branch 0 taken 3440640 times.
✓ Branch 1 taken 107520 times.
3548160 for ( int32_t q = 0; q < 32; q++ ) {
14532
1/2
✓ Branch 0 taken 3440640 times.
✗ Branch 1 not taken.
3440640 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14533 {
14534 return qe_invalid;
14535 }
14536 3440640 }
14537
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetw(&(tempguy.script),f))
14538 {
14539 return qe_invalid;
14540 }
14541
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for ( int32_t q = 0; q < 8; q++ )
14542 {
14543
1/2
✓ Branch 0 taken 860160 times.
✗ Branch 1 not taken.
860160 if(!p_igetl(&(tempguy.initD[q]),f))
14544 {
14545 return qe_invalid;
14546 }
14547 860160 }
14548
2/2
✓ Branch 0 taken 215040 times.
✓ Branch 1 taken 107520 times.
322560 for ( int32_t q = 0; q < 2; q++ )
14549 {
14550 int32_t temp;
14551
1/2
✓ Branch 0 taken 215040 times.
✗ Branch 1 not taken.
215040 if(!p_igetl(&temp,f))
14552 {
14553 return qe_invalid;
14554 }
14555 215040 }
14556
14557 107520 }
14558
14559
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion >= 37)
14560 {
14561
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.editorflags),f))
14562 {
14563 return qe_invalid;
14564 }
14565 107520 }
14566
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14567
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if(guyversion >= 38)
14568 {
14569
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.attributes[12]),f))
14570 {
14571 return qe_invalid;
14572 }
14573
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.attributes[13]),f))
14574 {
14575 return qe_invalid;
14576 }
14577
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.attributes[14]),f))
14578 {
14579 return qe_invalid;
14580 }
14581
14582 107520 }
14583
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion < 38 )
14584 {
14585 102400 tempguy.attributes[12] = 0;
14586 102400 tempguy.attributes[13] = 0;
14587 102400 tempguy.attributes[14] = 0;
14588 102400 }
14589
14590
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if ( guyversion >= 39 )
14591 {
14592
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 107520 times.
967680 for ( int32_t q = 0; q < 8; q++ )
14593 {
14594
2/2
✓ Branch 0 taken 55910400 times.
✓ Branch 1 taken 860160 times.
56770560 for ( int32_t w = 0; w < 65; w++ )
14595 {
14596
1/2
✓ Branch 0 taken 55910400 times.
✗ Branch 1 not taken.
55910400 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14597 {
14598 return qe_invalid;
14599 }
14600 55910400 }
14601
2/2
✓ Branch 0 taken 651264 times.
✓ Branch 1 taken 208896 times.
860160 if(guyversion < 54)
14602 {
14603 byte dummybyte;
14604
2/2
✓ Branch 0 taken 13578240 times.
✓ Branch 1 taken 208896 times.
13787136 for ( int32_t w = 0; w < 65; w++ )
14605
1/2
✓ Branch 0 taken 13578240 times.
✗ Branch 1 not taken.
13578240 if(!p_getc(&dummybyte,f))
14606 return qe_invalid;
14607 208896 }
14608 860160 }
14609
14610
14611 107520 }
14612
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion < 39 ) //apply old InitD strings to both
14613 {
14614
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ )
14615 {
14616 819200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14617 819200 }
14618 102400 }
14619
4/4
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 81408 times.
✓ Branch 3 taken 26112 times.
209920 if ( guyversion >= 40 && guyversion < 54)
14620
1/2
✓ Branch 0 taken 26112 times.
✗ Branch 1 not taken.
26112 if(!p_igetw(&(tempguy.weap_data.script),f))
14621 return qe_invalid;
14622
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if ( guyversion < 40 )
14623 102400 tempguy.weap_data.script = 0;
14624 //eweapon script InitD
14625
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
209920 if ( guyversion >= 41 )
14626 {
14627
2/2
✓ Branch 0 taken 81408 times.
✓ Branch 1 taken 26112 times.
107520 if(guyversion < 54)
14628
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 26112 times.
235008 for ( int32_t q = 0; q < 8; q++ )
14629
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14630 26112 return qe_invalid;
14631
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if ( guy_cversion < 4 )
14632 {
14633 if ( tempguy.type == eeKEESE )
14634 {
14635
14636 if ( !tempguy.attributes[0] )
14637 {
14638 tempguy.attributes[15] = 120;
14639 tempguy.attributes[16] = 16;
14640
14641 }
14642 }
14643 if ( tempguy.type == eePEAHAT )
14644 {
14645 tempguy.attributes[15] = 80;
14646 tempguy.attributes[16] = 16;
14647 }
14648
14649 if ( tempguy.type == eeGHINI )
14650 {
14651 tempguy.attributes[15] = 120;
14652 tempguy.attributes[16] = 10;
14653 }
14654
14655 }
14656 107520 }
14657
14658
14659
14660 //default weapon sprites (quest version < 2.54)
14661 //port over old defaults -Z
14662
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion < 32)
14663 {
14664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.wpnsprite <= 0 )
14665 {
14666
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14667 {
14668 case wNone:
14669 86878 tempguy.wpnsprite = 0; break;
14670
14671 case wSword:
14672 case wBeam:
14673 case wBrang:
14674 case wBomb:
14675 case wSBomb:
14676 case wLitBomb:
14677 case wLitSBomb:
14678 case wArrow:
14679 case wFire:
14680 case wWhistle:
14681 case wBait:
14682 case wWand:
14683 case wMagic:
14684 case wCatching:
14685 case wWind:
14686 case wRefMagic:
14687 case wRefFireball:
14688 case wRefRock:
14689 case wHammer:
14690 case wHookshot:
14691 case wHSHandle:
14692 case wHSChain:
14693 case wSSparkle:
14694 case wFSparkle:
14695 case wSmack:
14696 case wPhantom:
14697 case wCByrna:
14698 case wRefBeam:
14699 case wStomp:
14700 case lwMax:
14701 case wScript1:
14702 case wScript2:
14703 case wScript3:
14704 case wScript4:
14705 case wScript5:
14706 case wScript6:
14707 case wScript7:
14708 case wScript8:
14709 case wScript9:
14710 case wScript10:
14711 case wIce:
14712 //Cannot use any of these weapons yet.
14713 tempguy.wpnsprite = -1;
14714 break;
14715
14716 case wEnemyWeapons:
14717 2849 case ewFireball: tempguy.wpnsprite = 17; break;
14718
14719 801 case ewArrow: tempguy.wpnsprite = 19; break;
14720 691 case ewBrang: tempguy.wpnsprite = 4; break;
14721 1900 case ewSword: tempguy.wpnsprite = 20; break;
14722 1291 case ewRock: tempguy.wpnsprite = 18; break;
14723 2399 case ewMagic: tempguy.wpnsprite = 21; break;
14724 206 case ewBomb: tempguy.wpnsprite = 78; break;
14725 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14726 448 case ewLitBomb: tempguy.wpnsprite = 76; break;
14727 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14728 906 case ewFireTrail: tempguy.wpnsprite = 80; break;
14729 1802 case ewFlame: tempguy.wpnsprite = 35; break;
14730 229 case ewWind: tempguy.wpnsprite = 36; break;
14731 325 case ewFlame2: tempguy.wpnsprite = 81; break;
14732 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14733 case ewIce: tempguy.wpnsprite = 83; break;
14734 1519 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14735
14736
14737 default: break; //No assign.
14738 }
14739 102400 }
14740 102400 }
14741
14742 //default weapon fire sound (quest version < 2.54)
14743 //port over old defaults and zero new data. -Z
14744
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion < 34)
14745 {
14746
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 102400 times.
3379200 for ( int32_t q = 0; q < 32; q++ )
14747 {
14748 3276800 tempguy.movement[q] = 0;
14749 3276800 tempguy.new_weapon[q] = 0;
14750
14751 3276800 }
14752
14753 //NPC Script attributes.
14754 102400 tempguy.script = 0; //No scripted enemies existed. -Z
14755
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14756
14757
2/2
✓ Branch 0 taken 1740800 times.
✓ Branch 1 taken 102400 times.
1843200 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14758
14759 //old default sounds
14760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.firesfx <= 0 )
14761 {
14762
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14763 {
14764 case wNone:
14765 86878 tempguy.firesfx = 0; break;
14766
14767 case wSword:
14768 case wBeam:
14769 case wBrang:
14770 case wBomb:
14771 case wSBomb:
14772 case wLitBomb:
14773 case wLitSBomb:
14774 case wArrow:
14775 case wFire:
14776 case wWhistle:
14777 case wBait:
14778 case wWand:
14779 case wMagic:
14780 case wCatching:
14781 case wWind:
14782 case wRefMagic:
14783 case wRefFireball:
14784 case wRefRock:
14785 case wHammer:
14786 case wHookshot:
14787 case wHSHandle:
14788 case wHSChain:
14789 case wSSparkle:
14790 case wFSparkle:
14791 case wSmack:
14792 case wPhantom:
14793 case wCByrna:
14794 case wRefBeam:
14795 case wStomp:
14796 case lwMax:
14797 case wScript1:
14798 case wScript2:
14799 case wScript3:
14800 case wScript4:
14801 case wScript5:
14802 case wScript6:
14803 case wScript7:
14804 case wScript8:
14805 case wScript9:
14806 case wScript10:
14807 case wIce:
14808 //Cannot use any of these weapons yet.
14809 tempguy.firesfx = -1;
14810 break;
14811
14812 case wEnemyWeapons:
14813 2849 case ewFireball: tempguy.firesfx = 40; break;
14814
14815 801 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14816 691 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14817 1900 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14818 1291 case ewRock: tempguy.firesfx = 51; break;
14819 2399 case ewMagic: tempguy.firesfx = 32; break;
14820 206 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14821 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14822 448 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14823 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14824 906 case ewFireTrail: tempguy.firesfx = 13; break;
14825 1802 case ewFlame: tempguy.firesfx = 13; break;
14826 229 case ewWind: tempguy.firesfx = 32; break;
14827 325 case ewFlame2: tempguy.firesfx = 13; break;
14828 case ewFlame2Trail: tempguy.firesfx = 13; break;
14829 case ewIce: tempguy.firesfx = 44; break;
14830 1519 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14831
14832 //what about special attacks (e.g. summoning == 56)
14833 default: break; //No assign.
14834 }
14835 102400 }
14836 102400 }
14837
14838 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14839
4/6
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 107520 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 107520 times.
209920 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14840 {
14841
2/2
✓ Branch 0 taken 89799 times.
✓ Branch 1 taken 12601 times.
102400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14842 102400 }
14843 //Keese and bat halt rates.
14844
3/4
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 107520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102400 times.
209920 if ( guyversion < 42 && guy_cversion < 4 )
14845 {
14846
14847
2/2
✓ Branch 0 taken 101101 times.
✓ Branch 1 taken 1299 times.
102400 if ( tempguy.type == eeKEESE )
14848 {
14849
14850
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 364 times.
1299 if ( !tempguy.attributes[0] )
14851 {
14852 935 tempguy.attributes[15] = 120;
14853 935 tempguy.attributes[16] = 16;
14854
14855 935 }
14856 1299 }
14857
2/2
✓ Branch 0 taken 101935 times.
✓ Branch 1 taken 465 times.
102400 if ( tempguy.type == eePEAHAT )
14858 {
14859 465 tempguy.attributes[15] = 80;
14860 465 tempguy.attributes[16] = 16;
14861 465 }
14862
2/2
✓ Branch 0 taken 102200 times.
✓ Branch 1 taken 200 times.
102400 if ( tempguy.type == eeGHINI )
14863 {
14864 200 tempguy.attributes[15] = 120;
14865 200 tempguy.attributes[16] = 10;
14866 200 }
14867
14868
14869 102400 }
14870
14871
14872 //miscellaneous other corrections
14873 //fix the mirror wizzrobe -DD
14874
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 7)
14875 {
14876 if(i == eMWIZ)
14877 {
14878 tempguy.attributes[1] = 0;
14879 tempguy.attributes[3] = 1;
14880 }
14881 }
14882
14883
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 8)
14884 {
14885 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14886 {
14887 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14888 tempguy.attributes[4] = 4; //neck length in segments
14889 tempguy.attributes[5] = 8; //neck offset from first body tile
14890 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14891 tempguy.attributes[7] = 168; //head offset from first body tile
14892 tempguy.attributes[8] = 228; //flying head offset from first body tile
14893
14894 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14895 {
14896 tempguy.attributes[5] += 10; //neck offset from first body tile
14897 tempguy.attributes[7] -= 12; //head offset from first body tile
14898 }
14899 }
14900 }
14901
14902
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14903 {
14904 if(get_bit(deprecated_rules,46) && tempguy.type==eeDONGO && tempguy.attributes[0]==0)
14905 tempguy.bosspal = spDIG;
14906 }
14907
14908
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 11) // December 2007 - Spinning Tile fix
14909 {
14910 if(tempguy.type==eeSPINTILE)
14911 {
14912 tempguy.flags |= guy_superman;
14913 tempguy.item_set = 0; // Don't drop items
14914 tempguy.step = 300;
14915 }
14916 }
14917
14918
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14919 {
14920 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14921 {
14922 if(tempguy.type==eeROPE)
14923 {
14924 tempguy.flags &= ~guy_flashing;
14925 }
14926 }
14927
14928 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14929 {
14930 if(tempguy.type==eeBUBBLE)
14931 {
14932 tempguy.flags &= ~guy_flashing;
14933 }
14934 }
14935
14936 if((tempguy.type==eeGHINI)&&(tempguy.attributes[0]))
14937 {
14938 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14939 {
14940 tempguy.flags |= guy_blinking;
14941 }
14942
14943 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14944 {
14945 tempguy.flags |= guy_transparent;
14946 }
14947 }
14948 }
14949
14950
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14951 {
14952 if(i==gFIRE)
14953 {
14954 tempguy.e_anim = aFLIP;
14955 tempguy.e_frate = 24;
14956 }
14957
14958 if(i==gFAIRY)
14959 {
14960 tempguy.e_anim = a2FRM;
14961 tempguy.e_frate = 16;
14962 }
14963 }
14964
14965
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14966 {
14967 if(i==0) Z_message("Updating guys to version 16...\n");
14968
14969 update_guy_1(&tempguy);
14970
14971 if(i==eMPOLSV)
14972 {
14973 tempguy.defense[edefARROW] = edCHINK;
14974 tempguy.defense[edefMAGIC] = ed1HKO;
14975 tempguy.defense[edefREFMAGIC] = ed1HKO;
14976 }
14977 }
14978
14979
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 17) // December 2009
14980 {
14981 if(tempguy.type==eePROJECTILE)
14982 {
14983 tempguy.attributes[0] = 0;
14984 }
14985 }
14986
14987
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 18) // January 2010
14988 {
14989 bool boss = (tempguy.type == eeAQUA || tempguy.type==eeDONGO || tempguy.type == eeMANHAN || tempguy.type == eeGHOMA || tempguy.type==eeDIG
14990 || tempguy.type == eeGLEEOK || tempguy.type==eePATRA || tempguy.type == eeGANON || tempguy.type==eeMOLD);
14991
14992 tempguy.hitsfx = (boss && tempguy.type != eeMOLD && tempguy.type != eeDONGO && tempguy.type != eeDIG) ? WAV_GASP : 0;
14993 tempguy.deadsfx = (boss && (tempguy.type != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14994
14995 if(tempguy.type == eeAQUA)
14996 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14997 else if(tempguy.type == eeMANHAN)
14998 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14999 else if(tempguy.type==eePATRA)
15000 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15001 else if(tempguy.type==eeGHOMA)
15002 {
15003 for(int32_t j=0; j<edefLAST; j++)
15004 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15005
15006 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
15007
15008 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15009
15010 tempguy.attributes[0]--;
15011 }
15012 else if(tempguy.type == eeGLEEOK)
15013 {
15014 for(int32_t j=0; j<edefLAST; j++)
15015 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15016
15017 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15018 }
15019 else if(tempguy.type == eeARMOS)
15020 {
15021 tempguy.type=eeWALK;
15022 tempguy.hrate = 0;
15023 tempguy.attributes[9] = tempguy.attributes[0];
15024 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
15025 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
15026 tempguy.attributes[8] = e9tARMOS;
15027 }
15028 else if(tempguy.type == eeGHINI && !tempguy.attributes[0])
15029 {
15030 tempguy.type=eeWALK;
15031 tempguy.hrate = 0;
15032 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
15033 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
15034 }
15035
15036 // Spawn animation flags
15037 if(tempguy.type == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
15038 tempguy.flags |= guy_fade_flicker;
15039 else
15040 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
15041 }
15042
15043
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 20) // April 2010
15044 {
15045 if(tempguy.type == eeTRAP)
15046 {
15047 tempguy.attributes[1] = tempguy.attributes[9];
15048
15049 if(tempguy.attributes[9]>=1)
15050 {
15051 tempguy.attributes[0]++;
15052 }
15053
15054 tempguy.attributes[9] = 0;
15055 }
15056
15057 // Bomb Blast fix
15058 if(tempguy.weapon==ewBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15059 tempguy.weapon = ewLitBomb;
15060 else if(tempguy.weapon==ewSBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15061 tempguy.weapon = ewLitSBomb;
15062 }
15063
15064
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 21) // September 2011
15065 {
15066 if(tempguy.type == eeKEESE || tempguy.type == eeKEESETRIB)
15067 {
15068 if(tempguy.type == eeKEESETRIB)
15069 {
15070 tempguy.type = eeKEESE;
15071 tempguy.attributes[1] = e2tKEESETRIB;
15072 tempguy.attributes[0] = 0;
15073 }
15074
15075 tempguy.rate = 2;
15076 tempguy.hrate = 8;
15077 tempguy.homing = 0;
15078 tempguy.step= (tempguy.type == eeKEESE && tempguy.attributes[0] ? 100:62);
15079 }
15080 else if(tempguy.type == eePEAHAT || tempguy.type==eePATRA)
15081 {
15082 if(tempguy.type == eePEAHAT)
15083 {
15084 tempguy.rate = 4;
15085 tempguy.step = 62;
15086 }
15087 else
15088 tempguy.step = 25;
15089
15090 tempguy.hrate = 8;
15091 tempguy.homing = 0;
15092 }
15093 else if(tempguy.type == eeDIG || tempguy.type == eeMANHAN)
15094 {
15095 if(tempguy.type == eeMANHAN)
15096 tempguy.step=50;
15097
15098 tempguy.hrate = 16;
15099 tempguy.homing = 0;
15100 }
15101 else if(tempguy.type == eeGLEEOK)
15102 {
15103 tempguy.rate = 2;
15104 tempguy.homing = 0;
15105 tempguy.hrate = 9;
15106 tempguy.step=89;
15107 }
15108 else if(tempguy.type == eeGHINI)
15109 {
15110 tempguy.rate = 4;
15111 tempguy.hrate = 12;
15112 tempguy.step=62;
15113 tempguy.homing = 0;
15114 }
15115
15116 // Bigdig random rate fix
15117 if(tempguy.type==eeDIG && tempguy.attributes[9]==1)
15118 {
15119 tempguy.rate = 2;
15120 }
15121 }
15122
15123
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(guyversion < 24) // November 2012
15124 {
15125 if(tempguy.type==eeLANM)
15126 tempguy.attributes[2] = 1;
15127 else if(tempguy.type==eeMOLD)
15128 tempguy.attributes[1] = 0;
15129 }
15130
15131
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15132 {
15133
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 101000 times.
102400 if(tempguy.type!=eeDIG)
15134 {
15135 101000 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15136 101000 }
15137
15138 102400 }
15139 // does not seem to solve the issue!
15140
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if ( Header->zelda_version <= 0x210 )
15141 {
15142 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15143 if ( tempguy.type == eeDONGO )
15144 {
15145 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15146 }
15147 }
15148
15149
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion >= 42)
15150 {
15151
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 2560 times.
107520 if(guyversion >= 47)
15152 {
15153
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetl(&(tempguy.moveflags),f))
15154 {
15155 return qe_invalid;
15156 }
15157 104960 }
15158 else
15159 {
15160 byte fl;
15161
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15162 {
15163 return qe_invalid;
15164 }
15165 2560 tempguy.moveflags = (move_flags)fl;
15166 }
15167 107520 }
15168 else
15169 {
15170
7/8
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 80670 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 642 times.
✓ Branch 6 taken 498 times.
✓ Branch 7 taken 13859 times.
102400 switch(tempguy.type)
15171 {
15172 //No gravity; floats over pits
15173 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15174 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15175 //Special (bosses, etc)
15176 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15177 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15178 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15179 80670 tempguy.moveflags = move_can_pitwalk;
15180 80670 break;
15181 //No gravity, but falls in pits
15182 case eeLEV:
15183 958 tempguy.moveflags = move_can_pitfall;
15184 958 break;
15185 //Bosses that respect pits
15186 case eeDONGO:
15187 642 tempguy.moveflags = move_obeys_grav;
15188 642 break;
15189 case eeLANM:
15190 498 tempguy.moveflags = move_none;
15191 498 break;
15192 //Gravity, floats over pits
15193 case eeWIZZ: case eeWALLM: case eeGHINI:
15194 2717 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15195 2717 break;
15196 //Gravity and falls in pits
15197 case eeWALK:
15198
4/4
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12635 times.
13859 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15199 1224 break;
15200 [[fallthrough]];
15201 case eeOTHER:
15202 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15203 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15204 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15205 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15206 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15207 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15208 15691 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15209 15691 }
15210 }
15211
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion < 43)
15212 {
15213
2/2
✓ Branch 0 taken 83387 times.
✓ Branch 1 taken 19013 times.
102400 switch(tempguy.type)
15214 {
15215 //No gravity; floats over pits
15216 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15217 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15218 //Special (bosses, etc)
15219 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15220 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15221 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15222 case eeWIZZ: case eeWALLM: case eeGHINI:
15223 //Gravity, floats over pits
15224 83387 tempguy.moveflags |= move_can_waterwalk;
15225 83387 tempguy.moveflags |= move_can_pitwalk;
15226 83387 break;
15227 }
15228 102400 }
15229
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if (guyversion < 44)
15230 {
15231
2/2
✓ Branch 0 taken 101487 times.
✓ Branch 1 taken 913 times.
102400 if ( tempguy.type == eeGHOMA )
15232 {
15233 913 tempguy.flags |= guy_fade_instant;
15234 913 }
15235 102400 }
15236
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if (guyversion > 44)
15237 {
15238
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_getc(&(tempguy.spr_shadow),f))
15239 {
15240 return qe_invalid;
15241 }
15242
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_getc(&(tempguy.spr_death),f))
15243 {
15244 return qe_invalid;
15245 }
15246
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_getc(&(tempguy.spr_spawn),f))
15247 {
15248 return qe_invalid;
15249 }
15250 107520 }
15251 else
15252 {
15253
2/2
✓ Branch 0 taken 102003 times.
✓ Branch 1 taken 397 times.
102400 tempguy.spr_shadow = (tempguy.type==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15254 102400 tempguy.spr_death = iwDeath;
15255 102400 tempguy.spr_spawn = iwSpawn;
15256 }
15257
15258
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 102400 times.
209920 if(guyversion < 46)
15259 {
15260
4/4
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 88541 times.
✓ Branch 2 taken 13164 times.
✓ Branch 3 taken 695 times.
102400 if(tempguy.type == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15261 {
15262 695 tempguy.moveflags |= move_can_waterwalk;
15263 695 }
15264 102400 }
15265
15266
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 104960 times.
209920 if (guyversion < 47)
15267 {
15268
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 574 times.
104960 if (tempguy.type == eeDIG && tempguy.attributes[9]!=1)
15269 {
15270 574 tempguy.flags |= guy_ignore_kill_all;
15271 574 }
15272 104960 }
15273
15274
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 125440 times.
209920 if (guyversion < 49)
15275 {
15276
8/8
✓ Branch 0 taken 16388 times.
✓ Branch 1 taken 109052 times.
✓ Branch 2 taken 15916 times.
✓ Branch 3 taken 472 times.
✓ Branch 4 taken 15433 times.
✓ Branch 5 taken 483 times.
✓ Branch 6 taken 528 times.
✓ Branch 7 taken 14905 times.
125440 if (tempguy.type == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15277 {
15278
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 712 times.
✓ Branch 3 taken 61 times.
1483 switch (tempguy.attributes[7]) {
15279 case 0: //Sword
15280 710 tempguy.attributes[7] = e8tSWORD;
15281 710 break;
15282 case 1: //Item
15283 712 tempguy.attributes[7] = e8tITEM;
15284 712 break;
15285 case 2: //Both
15286 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15287 61 break;
15288 default: //this can actually happen since Misc8 can be set to any number.
15289 tempguy.attributes[7] = 0;
15290 break;
15291 }
15292 1483 }
15293 125440 }
15294
15295 //these could possible be combined but rather be safe...
15296
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 125440 times.
209920 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15297 {
15298 125440 guy_update_firesfx(tempguy);
15299 125440 }
15300
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 84480 times.
209920 if (guyversion < 52)
15301 {
15302 125440 guy_update_weaponflags(tempguy);
15303 125440 }
15304
2/2
✓ Branch 0 taken 81408 times.
✓ Branch 1 taken 3072 times.
84480 else if(guyversion < 54)
15305 {
15306
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15307 return qe_invalid;
15308
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15309 return qe_invalid;
15310
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15311 return qe_invalid;
15312
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15313 return qe_invalid;
15314
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15315 return qe_invalid;
15316
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15317 return qe_invalid;
15318
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15319 return qe_invalid;
15320
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15321 return qe_invalid;
15322
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15323 return qe_invalid;
15324
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15325 return qe_invalid;
15326
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15327 return qe_invalid;
15328
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15329 return qe_invalid;
15330 int32_t temp_step;
15331
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&temp_step, f))
15332 return qe_invalid;
15333 3072 tempguy.weap_data.step = zslongToFix(temp_step*100);
15334
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 3072 times.
18432 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15335 {
15336
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15337 return qe_invalid;
15338
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15339 return qe_invalid;
15340 15360 }
15341 3072 }
15342
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 84480 times.
209920 if (guyversion < 53)
15343 {
15344 125440 guy_update_weaponspecialsfx(tempguy);
15345 125440 }
15346 else
15347 {
15348
1/2
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
84480 if (!p_getc(&(tempguy.specialsfx), f))
15349 return qe_invalid;
15350 }
15351
15352
2/2
✓ Branch 0 taken 81408 times.
✓ Branch 1 taken 128512 times.
209920 if(guyversion >= 54)
15353 {
15354
1/2
✓ Branch 0 taken 81408 times.
✗ Branch 1 not taken.
81408 if(auto ret = read_weap_data(tempguy.weap_data, f))
15355 return ret;
15356 81408 }
15357 else
15358 {
15359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128512 times.
128512 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15360 128512 tempguy.weap_data.flags |= wdata_set_step;
15361
2/2
✓ Branch 0 taken 126931 times.
✓ Branch 1 taken 1581 times.
128512 if(tempguy.weapon == ewRock)
15362 1581 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15363 }
15364
15365
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15366 {
15367 tempguy.script = 0;
15368 for(int q = 0; q < 8; ++q)
15369 tempguy.initD[q] = 0;
15370 }
15371 209920 guysbuf[i] = tempguy;
15372 209920 }
15373 410 }
15374
15375 410 return 0;
15376 492 }
15377
15378 void update_guy_1(guydata *tempguy) // November 2009
15379 {
15380 bool doesntcount = false;
15381 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15382
15383 switch(tempguy->type)
15384 {
15385 case 1: //eeWALK
15386 switch(tempguy->attributes[9])
15387 {
15388 case 0: //Stalfos
15389 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15390 tempguy->attributes[0]=4;
15391
15392 break;
15393
15394 case 1: //Darknut
15395 goto darknuts;
15396 break;
15397 }
15398
15399 tempguy->attributes[9] = 0;
15400 break;
15401
15402 case 2: //eeSHOOT
15403 tempguy->type = eeWALK;
15404
15405 switch(tempguy->attributes[9])
15406 {
15407 case 0: //Octorok
15408 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15409 {
15410 tempguy->attributes[0]=e1tFIREOCTO;
15411 tempguy->attributes[1]=e2tFIREOCTO;
15412 }
15413 else tempguy->attributes[0] = 0;
15414
15415 tempguy->attributes[5]=tempguy->attributes[3];
15416 tempguy->attributes[3]=tempguy->attributes[2];
15417 tempguy->attributes[2]=0;
15418 break;
15419
15420 case 1: // Moblin
15421 tempguy->attributes[0] = 0;
15422 break;
15423
15424 case 2: //Lynel
15425 tempguy->attributes[5]=tempguy->attributes[0]+1;
15426 tempguy->attributes[0]=0;
15427 break;
15428
15429 case 3: //Stalfos 2
15430 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15431 tempguy->attributes[0]=e1t4SHOTS;
15432 else tempguy->attributes[0] = 0;
15433
15434 break;
15435
15436 case 4: //Darknut 5
15437 darknuts:
15438 tempguy->defense[edefFIRE] = edIGNORE;
15439 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15440 tempguy->defense[edefHOOKSHOT] = 0;
15441 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15442 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15443
15444 if(tempguy->attributes[0]==1)
15445 tempguy->attributes[0]=2;
15446 else if(tempguy->attributes[0]==2)
15447 {
15448 tempguy->attributes[3]=tempguy->attributes[2];
15449 tempguy->attributes[2]=tempguy->attributes[1];
15450 tempguy->attributes[1]=e2tSPLIT;
15451 tempguy->attributes[0] = 0;
15452 }
15453 else tempguy->attributes[0] = 0;
15454
15455 tempguy->flags |= guy_shield_front;
15456
15457 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15458 tempguy->flags &= ~guy_bkshield;
15459 else
15460 tempguy->flags |= guy_bkshield;
15461
15462 break;
15463 }
15464
15465 tempguy->attributes[9] = 0;
15466 break;
15467
15468 /*
15469 case 9: //eeARMOS
15470 tempguy->family = eeWALK;
15471 break;
15472 */
15473 case 11: //eeGEL
15474 case 33: //eeGELTRIB
15475 if(tempguy->type==33)
15476 {
15477 tempguy->attributes[3] = 1;
15478
15479 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15480 tempguy->attributes[2] = tempguy->attributes[1];
15481
15482 tempguy->attributes[1] = e2tTRIBBLE;
15483 }
15484 else
15485 {
15486 tempguy->attributes[3] = 0;
15487 tempguy->attributes[2] = 0;
15488 tempguy->attributes[1] = 0;
15489 }
15490
15491 tempguy->type = eeWALK;
15492
15493 if(tempguy->attributes[0])
15494 {
15495 tempguy->attributes[0]=1;
15496 tempguy->weapon = ewFireTrail;
15497 }
15498
15499 break;
15500
15501 case 34: //eeZOLTRIB
15502 case 12: //eeZOL
15503 tempguy->attributes[3]=tempguy->attributes[2];
15504 tempguy->attributes[2]=tempguy->attributes[1];
15505 tempguy->type = eeWALK;
15506 tempguy->attributes[1]=e2tSPLITHIT;
15507
15508 if(tempguy->attributes[0])
15509 {
15510 tempguy->attributes[0]=1;
15511 tempguy->weapon = ewFireTrail;
15512 }
15513
15514 break;
15515
15516 case 13: //eeROPE
15517 tempguy->type = eeWALK;
15518 tempguy->attributes[8] = e9tROPE;
15519
15520 if(tempguy->attributes[0])
15521 {
15522 tempguy->attributes[3] = tempguy->attributes[2];
15523 tempguy->attributes[2] = tempguy->attributes[1];
15524 tempguy->attributes[1] = e2tBOMBCHU;
15525 }
15526
15527 tempguy->attributes[0] = 0;
15528 break;
15529
15530 case 14: //eeGORIYA
15531 tempguy->type = eeWALK;
15532
15533 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15534
15535 break;
15536
15537 case 17: //eeBUBBLE
15538 tempguy->type = eeWALK;
15539 tempguy->attributes[7] = tempguy->attributes[1];
15540 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15541 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15542
15543 //fallthrogh
15544 case eeTRAP:
15545 case eeROCK:
15546 doesntcount = true;
15547 break;
15548
15549 case 35: //eeVIRETRIB
15550 case 18: //eeVIRE
15551 tempguy->type = eeWALK;
15552 tempguy->attributes[3]=tempguy->attributes[2];
15553 tempguy->attributes[2]=tempguy->attributes[1];
15554 tempguy->attributes[1]=e2tSPLITHIT;
15555 tempguy->attributes[8]=e9tVIRE;
15556 break;
15557
15558 case 19: //eeLIKE
15559 tempguy->type = eeWALK;
15560 tempguy->attributes[6] = e7tEATITEMS;
15561 tempguy->attributes[7]=95;
15562 break;
15563
15564 case 20: //eePOLSV
15565 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15566 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15567 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15568 tempguy->defense[edefARROW] = ed1HKO;
15569 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15570 tempguy->type = eeWALK;
15571 tempguy->attributes[8] = e9tPOLSVOICE;
15572 tempguy->rate = 4;
15573 tempguy->homing = 32;
15574 tempguy->hrate = 10;
15575 tempguy->grumble = 0;
15576 break;
15577
15578 case eeWIZZ:
15579 if(tempguy->attributes[3])
15580 {
15581 for(int32_t i=0; i < edefLAST; i++)
15582 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15583 }
15584 else
15585 {
15586 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15587 tempguy->defense[edefMAGIC] = edCHINK;
15588 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15589 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15590 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15591 }
15592
15593 break;
15594
15595 case eePEAHAT:
15596 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15597
15598 if(!(tempguy->flags & guy_bhit))
15599 tempguy->defense[edefBRANG] = edSTUNONLY;
15600
15601 break;
15602
15603 case eeLEV:
15604 tempguy->defense[edefSTOMP] = edCHINK;
15605 break;
15606 }
15607
15608 // Old flags
15609 if(tempguy->flags & guy_superman)
15610 {
15611 for(int32_t i = 0; i < edefLAST; i++)
15612 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15613 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15614 && tempguy->type != eeROCK && tempguy->type != eeTRAP
15615 && tempguy->type != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15616 }
15617
15618 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15619
15620 if(doesntcount)
15621 tempguy->flags |= (guy_doesnt_count);
15622 }
15623
15624 1178856 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15625 {
15626 1178856 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15627
15628 byte tempbyte, padding;
15629 word wpadding;
15630 int32_t extras, secretcombos;
15631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->valid),f))
15632 {
15633 return qe_invalid;
15634 }
15635
15636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->guy),f))
15637 return qe_invalid;
15638 1178856 temp_mapscr->guytile = -1; //signal to use default guy values
15639
2/2
✓ Branch 0 taken 1178256 times.
✓ Branch 1 taken 600 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15640
4/4
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1178256 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 538 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15641
15642
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15643 {
15644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15645 {
15646 return qe_invalid;
15647 }
15648
15649 22176 temp_mapscr->str=tempbyte;
15650 22176 }
15651 else
15652 {
15653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->str),f))
15654 {
15655 return qe_invalid;
15656 }
15657 }
15658
15659
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->room),f))
15660 {
15661 return qe_invalid;
15662 }
15663
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->item),f))
15665 {
15666 return qe_invalid;
15667 }
15668
15669
3/6
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 650352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15670 {
15671 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15672 528504 }
15673 else
15674 {
15675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->hasitem),f))
15676 return qe_invalid;
15677 }
15678
15679
3/4
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1181576 if((Header->zelda_version < 0x192)||
15680
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15681 {
15682
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15683 {
15684 return qe_invalid;
15685 }
15686 22176 }
15687
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15689 {
15690 return qe_invalid;
15691 }
15692
15693
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15694 {
15695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15696 {
15697 return qe_invalid;
15698 }
15699 24896 }
15700
15701
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15702 {
15703
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15704 {
15705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15706 {
15707 return qe_invalid;
15708 }
15709 1951056 }
15710 650352 }
15711 else
15712 {
15713 528504 temp_mapscr->tilewarptype[1]=0;
15714 528504 temp_mapscr->tilewarptype[2]=0;
15715 528504 temp_mapscr->tilewarptype[3]=0;
15716 }
15717
15718
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15719 {
15720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15721 {
15722 return qe_invalid;
15723 }
15724 1156680 }
15725
15726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15727 {
15728 return qe_invalid;
15729 }
15730
15731 1178856 temp_mapscr->warpreturnx[1]=0;
15732 1178856 temp_mapscr->warpreturnx[2]=0;
15733 1178856 temp_mapscr->warpreturnx[3]=0;
15734
15735
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15736 {
15737
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15738 {
15739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15740 {
15741 return qe_invalid;
15742 }
15743 1951056 }
15744 650352 }
15745
15746
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15747 {
15748 return qe_invalid;
15749 }
15750
15751 1178856 temp_mapscr->warpreturny[1]=0;
15752 1178856 temp_mapscr->warpreturny[2]=0;
15753 1178856 temp_mapscr->warpreturny[3]=0;
15754
15755
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15756 {
15757
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15758 {
15759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15760 {
15761 return qe_invalid;
15762 }
15763 1951056 }
15764
15765
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(version>=18)
15766 {
15767
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15768 {
15769 return qe_invalid;
15770 }
15771 650352 }
15772 else
15773 {
15774 byte temp;
15775
15776 if(!p_getc(&temp,f))
15777 {
15778 return qe_invalid;
15779 }
15780
15781 temp_mapscr->warpreturnc=temp<<8|temp;
15782 }
15783 650352 }
15784
15785
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->stairx),f))
15786
15787 {
15788 return qe_invalid;
15789 }
15790
15791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->stairy),f))
15792 {
15793 return qe_invalid;
15794 }
15795
15796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemx),f))
15797 {
15798 return qe_invalid;
15799 }
15800
15801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemy),f))
15802 {
15803 return qe_invalid;
15804 }
15805
15806
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version > 15) // February 2009
15807 {
15808
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->color),f))
15809 {
15810 return qe_invalid;
15811 }
15812 650352 }
15813 else
15814 {
15815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15816 {
15817 return qe_invalid;
15818 }
15819
15820 528504 temp_mapscr->color = (word) tempbyte;
15821 }
15822
15823
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags11),f))
15824 {
15825 return qe_invalid;
15826 }
15827
15828
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15829 {
15830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->door[k]),f))
15831 {
15832 return qe_invalid;
15833
15834 }
15835 4715424 }
15836
15837
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
15838 {
15839
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15840 {
15841 return qe_invalid;
15842 }
15843
15844 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15845
15846
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15847 {
15848 for(int32_t i=1; i<4; i++)
15849 {
15850 if(!p_getc(&(tempbyte),f))
15851 {
15852 return qe_invalid;
15853 }
15854
15855 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15856 }
15857 }
15858 else
15859 {
15860 528504 temp_mapscr->tilewarpdmap[1]=0;
15861 528504 temp_mapscr->tilewarpdmap[2]=0;
15862 528504 temp_mapscr->tilewarpdmap[3]=0;
15863 }
15864 528504 }
15865 else
15866 {
15867
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
15868 {
15869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15870 {
15871 return qe_invalid;
15872 }
15873 2601408 }
15874 }
15875
15876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15877 {
15878 return qe_invalid;
15879 }
15880
15881
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15882 {
15883
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15884 {
15885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15886 {
15887 return qe_invalid;
15888 }
15889 1951056 }
15890 650352 }
15891 else
15892 {
15893 528504 temp_mapscr->tilewarpscr[1]=0;
15894 528504 temp_mapscr->tilewarpscr[2]=0;
15895 528504 temp_mapscr->tilewarpscr[3]=0;
15896 }
15897
15898
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15899 {
15900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15901 {
15902 return qe_invalid;
15903 }
15904 650352 }
15905 else
15906 {
15907 528504 temp_mapscr->tilewarpoverlayflags=0;
15908 }
15909
15910
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->exitdir),f))
15911 {
15912 return qe_invalid;
15913 }
15914
15915
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15916 {
15917
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15918 {
15919 return qe_invalid;
15920 }
15921
15922 24896 }
15923
15924
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15925 {
15926 if(!p_getc(&padding,f))
15927 {
15928 return qe_invalid;
15929 }
15930 }
15931
15932
2/2
✓ Branch 0 taken 11788560 times.
✓ Branch 1 taken 1178856 times.
12967416 for(int32_t k=0; k<10; k++)
15933 {
15934
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15935 {
15936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15937 {
15938 return qe_invalid;
15939 }
15940
15941 221760 temp_mapscr->enemy[k]=tempbyte;
15942
15943 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
15944 // from corrupting when 1.90 saved the quest.
15945 // https://discord.com/channels/876899628556091432/1287580827164737658
15946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
15947 {
15948
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
15949 {
15950 temp_mapscr->enemy[k] = 0;
15951 }
15952 221760 }
15953 221760 }
15954 else
15955 {
15956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11566800 times.
11566800 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15957 {
15958 return qe_invalid;
15959 }
15960 }
15961
15962
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15963 {
15964 //using enumerations here is dangerous
15965 //very easy to break old quests -DD
15966
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15967 {
15968 1342 temp_mapscr->enemy[k]+=5;
15969 1342 }
15970
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15971 {
15972 94 temp_mapscr->enemy[k]+=1;
15973 94 }
15974 221760 }
15975
15976
2/2
✓ Branch 0 taken 6503520 times.
✓ Branch 1 taken 5285040 times.
11788560 if(version < 9)
15977 {
15978
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15979 {
15980 275905 temp_mapscr->enemy[k]+=10;
15981 275905 }
15982 5285040 }
15983 //don't read in any invalid data
15984
2/2
✓ Branch 0 taken 11788110 times.
✓ Branch 1 taken 450 times.
11788560 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15985 {
15986 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15987 450 temp_mapscr->enemy[k] = 0;
15988 450 }
15989 11788560 }
15990
15991
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->pattern),f))
15992 {
15993 return qe_invalid;
15994 }
15995
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15997 {
15998 return qe_invalid;
15999 }
16000
16001
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16002 {
16003
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
16004 {
16005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16006 {
16007 return qe_invalid;
16008 }
16009 1951056 }
16010 650352 }
16011 else
16012 {
16013 528504 temp_mapscr->sidewarptype[1]=0;
16014 528504 temp_mapscr->sidewarptype[2]=0;
16015 528504 temp_mapscr->sidewarptype[3]=0;
16016 }
16017
16018
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
16019 {
16020
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16021 {
16022 return qe_invalid;
16023 }
16024 650352 }
16025 else
16026 {
16027 528504 temp_mapscr->sidewarpoverlayflags=0;
16028 }
16029
16030
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16031 {
16032 return qe_invalid;
16033 }
16034
16035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16036 {
16037 return qe_invalid;
16038 }
16039
16040
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16041 {
16042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->path[k]),f))
16043 {
16044 return qe_invalid;
16045 }
16046 4715424 }
16047
16048
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
16049 {
16050 return qe_invalid;
16051 }
16052
16053
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16054 {
16055
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 1951056 times.
2601408 for(int32_t i=1; i<4; i++)
16056 {
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16058 {
16059 return qe_invalid;
16060 }
16061 1951056 }
16062 650352 }
16063 else
16064 {
16065 528504 temp_mapscr->sidewarpscr[1]=0;
16066 528504 temp_mapscr->sidewarpscr[2]=0;
16067 528504 temp_mapscr->sidewarpscr[3]=0;
16068 }
16069
16070
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
16071 {
16072
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
16073 {
16074 return qe_invalid;
16075 }
16076
16077 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16078
16079
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16080 {
16081 for(int32_t i=1; i<4; i++)
16082 {
16083 if(!p_getc(&(tempbyte),f))
16084 {
16085 return qe_invalid;
16086 }
16087
16088 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16089 }
16090 }
16091 else
16092 {
16093 528504 temp_mapscr->sidewarpdmap[1]=0;
16094 528504 temp_mapscr->sidewarpdmap[2]=0;
16095 528504 temp_mapscr->sidewarpdmap[3]=0;
16096 }
16097 528504 }
16098 else
16099 {
16100
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
16101 {
16102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16103 {
16104 return qe_invalid;
16105 }
16106 2601408 }
16107 }
16108
16109
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16110 {
16111
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16112 {
16113 return qe_invalid;
16114 }
16115 650352 }
16116 528504 else temp_mapscr->sidewarpindex = 0;
16117
16118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_igetw(&(temp_mapscr->undercombo),f))
16119 {
16120 return qe_invalid;
16121 }
16122
16123 1178856 byte old_combo_page = 0;
16124
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16125 {
16126
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16127 {
16128 return qe_invalid;
16129 }
16130
16131
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16132 {
16133 24624 old_combo_pages[scrind] = old_combo_page;
16134 24624 }
16135 24896 }
16136
16137
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16138 {
16139 return qe_invalid;
16140 }
16141
16142
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_igetw(&(temp_mapscr->catchall),f))
16143 {
16144 return qe_invalid;
16145 }
16146
16147
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags),f))
16148 {
16149 return qe_invalid;
16150 }
16151
16152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags2),f))
16153 {
16154 return qe_invalid;
16155 }
16156
16157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags3),f))
16158 {
16159 return qe_invalid;
16160 }
16161
16162
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16163 //if (version>2)
16164 {
16165
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags4),f))
16166 {
16167 return qe_invalid;
16168 }
16169 650352 }
16170
16171
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16172 {
16173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags5),f))
16174 {
16175 return qe_invalid;
16176 }
16177
16178
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16179 return qe_invalid;
16180 650352 temp_mapscr->noreset = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED;
16181
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16182 return qe_invalid;
16183 1300704 temp_mapscr->nocarry = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED |
16184 650352 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16185
16186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(temp_mapscr->flags5&32)
16187 {
16188 temp_mapscr->flags5 &= ~32;
16189 temp_mapscr->noreset |= 48;
16190 }
16191
16192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(version<8)
16193 {
16194 if(temp_mapscr->noreset&1)
16195 {
16196 temp_mapscr->noreset|=8192;
16197 }
16198
16199 if(temp_mapscr->nocarry&1)
16200 {
16201 temp_mapscr->nocarry|=8192;
16202 temp_mapscr->nocarry&=~1;
16203 }
16204 }
16205 650352 }
16206 else
16207 {
16208 528504 temp_mapscr->flags5 = 0;
16209 528504 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
16210 528504 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
16211 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16212 }
16213
16214
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16215 {
16216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags6),f))
16217 {
16218 return qe_invalid;
16219 }
16220 650352 }
16221
16222
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>5)
16223 {
16224
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags7),f))
16225 {
16226 return qe_invalid;
16227 }
16228
16229
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags8),f))
16230 {
16231 return qe_invalid;
16232 }
16233
16234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags9),f))
16235 {
16236 return qe_invalid;
16237 }
16238
16239
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags10),f))
16240 {
16241 return qe_invalid;
16242 }
16243
16244
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->csensitive),f))
16245 {
16246 return qe_invalid;
16247 }
16248 650352 }
16249 else
16250 {
16251 528504 temp_mapscr->csensitive=1;
16252 }
16253
16254
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<14) // August 2007: screen SFX added
16255 {
16256
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16257 {
16258 994 temp_mapscr->bosssfx=
16259
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16260 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16261 WAV_ROAR;
16262 994 }
16263
16264
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16265 {
16266 170 temp_mapscr->oceansfx=WAV_SEA;
16267 170 }
16268
16269 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16270 ? 0 : WAV_SECRET;
16271
16272 528504 temp_mapscr->flags3 &= ~66; //64|2
16273 528504 temp_mapscr->flags2 &= ~32;
16274 528504 temp_mapscr->flags &= ~136; // 128|8
16275 528504 }
16276 else
16277 {
16278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->oceansfx),f))
16279 {
16280 return qe_invalid;
16281 }
16282
16283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->bosssfx),f))
16284 {
16285 return qe_invalid;
16286 }
16287
16288
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->secretsfx),f))
16289 {
16290 return qe_invalid;
16291 }
16292 }
16293
16294
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<15) // October 2007: another SFX
16295 {
16296 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16297 528504 }
16298 else
16299 {
16300
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16301 {
16302 return qe_invalid;
16303 }
16304 }
16305
16306
16307
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16308 {
16309
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16310 {
16311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16312 {
16313 return qe_invalid;
16314 }
16315 6940080 }
16316
16317
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 6940080 times.
8096760 for(int32_t k=0; k<6; k++)
16318 {
16319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16320 {
16321 return qe_invalid;
16322 }
16323 6940080 }
16324 1156680 }
16325
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16326 {
16327 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16328 {
16329 return qe_invalid;
16330 }
16331
16332 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16333 {
16334 return qe_invalid;
16335 }
16336
16337 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16338 {
16339 return qe_invalid;
16340 }
16341
16342 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16343
16344 {
16345 return qe_invalid;
16346 }
16347 }
16348
16349
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>149))
16350 {
16351
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16352 {
16353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16354 {
16355 return qe_invalid;
16356 }
16357 16320 }
16358
16359
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16360 {
16361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16362 {
16363 return qe_invalid;
16364 }
16365 16320 }
16366
16367
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16368 {
16369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16370 {
16371 return qe_invalid;
16372 }
16373 16320 }
16374
16375
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16376 {
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16378 {
16379 return qe_invalid;
16380 }
16381 16320 }
16382
16383
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16384 {
16385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16386 {
16387 return qe_invalid;
16388 }
16389 16320 }
16390
16391
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16392 {
16393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16394 {
16395 return qe_invalid;
16396 }
16397 16320 }
16398 2720 }
16399
16400
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16401 {
16402
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16403 {
16404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16405 {
16406 return qe_invalid;
16407 }
16408 6940080 }
16409 1156680 }
16410
16411
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16412 {
16413
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 if((Header->zelda_version == 0x192)&&(Header->build>153))
16414 {
16415
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16416 {
16417 return qe_invalid;
16418 }
16419 2720 }
16420
16421
1/2
✓ Branch 0 taken 1156680 times.
✗ Branch 1 not taken.
1156680 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16422 {
16423 return qe_invalid;
16424 }
16425 1156680 }
16426
16427
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16428 {
16429 22176 extras=15;
16430 22176 }
16431
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16432 {
16433 extras=11;
16434 }
16435
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16436 {
16437 extras=32;
16438 }
16439
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16440 {
16441 extras=64;
16442 }
16443
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 else if(Header->zelda_version < 0x193)
16444 {
16445 2720 extras=62;
16446 2720 }
16447 else
16448
16449 {
16450 1153960 extras=0;
16451 }
16452
16453
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1178856 times.
1680136 for(int32_t k=0; k<extras; k++)
16454 {
16455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16456 {
16457 return qe_invalid;
16458 }
16459 501280 }
16460
16461
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16462 //if (version>3)
16463 {
16464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->nextmap),f))
16465 {
16466 return qe_invalid;
16467 }
16468
16469
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->nextscr),f))
16470 {
16471 return qe_invalid;
16472 }
16473 650352 }
16474 else
16475 {
16476 528504 temp_mapscr->nextmap=0;
16477 528504 temp_mapscr->nextscr=0;
16478 }
16479
16480
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16481 {
16482 22176 secretcombos=20;
16483 22176 }
16484
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16485 {
16486 secretcombos=256;
16487 }
16488 else
16489 {
16490 1156680 secretcombos=128;
16491 }
16492
16493
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16494 {
16495
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16496 {
16497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16498 {
16499 return qe_invalid;
16500 }
16501
16502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16503 {
16504 443520 temp_mapscr->secretcombo[k]=tempbyte;
16505 443520 }
16506 443520 }
16507 22176 }
16508 else
16509 {
16510
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16511 {
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16513 {
16514 return qe_invalid;
16515 }
16516
16517 148055040 }
16518 }
16519
16520
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16521 {
16522
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16523 {
16524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16525 {
16526 return qe_invalid;
16527 }
16528 148055040 }
16529
16530
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16531 {
16532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16533 {
16534 return qe_invalid;
16535 }
16536 148055040 }
16537 1156680 }
16538
16539
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16540 {
16541 if(!p_getc(&padding,f))
16542 {
16543 return qe_invalid;
16544 }
16545 }
16546
16547
2/2
✓ Branch 0 taken 207478656 times.
✓ Branch 1 taken 1178856 times.
208657512 for(int32_t k=0; k<176; k++)
16548 {
16549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207478656 times.
207478656 if(!p_igetw(&(temp_mapscr->data[k]),f))
16550 {
16551 return qe_invalid;
16552 }
16553 207478656 }
16554
16555
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16556 {
16557 if(!p_getc(&padding,f))
16558 {
16559 return qe_invalid;
16560 }
16561
16562 if(!p_getc(&padding,f))
16563 {
16564 return qe_invalid;
16565 }
16566 }
16567
16568
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16569 {
16570
2/2
✓ Branch 0 taken 203575680 times.
✓ Branch 1 taken 1156680 times.
204732360 for(int32_t k=0; k<176; k++)
16571 {
16572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16573 {
16574 return qe_invalid;
16575 }
16576
16577
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 203096960 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
203575680 if((Header->zelda_version == 0x192)&&(Header->build<24))
16578 {
16579 if(!p_getc(&tempbyte,f))
16580 {
16581 return qe_invalid;
16582 }
16583
16584 if(!p_getc(&tempbyte,f))
16585 {
16586 return qe_invalid;
16587 }
16588
16589 if(!p_getc(&tempbyte,f))
16590 {
16591 return qe_invalid;
16592 }
16593 }
16594 203575680 }
16595 1156680 }
16596
16597
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16598 {
16599
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 203575680 times.
204732360 for(int32_t k=0; k<176; k++)
16600 {
16601
16602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->cset[k]),f))
16603 {
16604 return qe_invalid;
16605 }
16606 203575680 }
16607 1156680 }
16608
16609
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16610 {
16611 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16612 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16613 22176 }
16614
16615
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16616 {
16617 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16618 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16619 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16620 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16621 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16622 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16623 22176 }
16624
16625
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16626 {
16627
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16628 {
16629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16630 {
16631 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16632 {
16633 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16634 }
16635 }
16636 else
16637 {
16638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16639 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16640 {
16641 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16642 3902976 }
16643
16644 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16645 }
16646
16647 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16648 3902976 }
16649 22176 }
16650
16651 /*if(version>12)
16652 {
16653 if(!p_getc(&(temp_mapscr->scrWidth),f))
16654 {
16655 return qe_invalid;
16656 }
16657 if(!p_getc(&(temp_mapscr->scrHeight),f))
16658 {
16659 return qe_invalid;
16660 }
16661 }*/
16662
16663
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>4)
16664 {
16665
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16666 {
16667 return qe_invalid;
16668 }
16669 650352 }
16670 else
16671 {
16672 528504 temp_mapscr->screen_midi = -1;
16673 }
16674
16675
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>=17)
16676 {
16677
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->lens_layer),f))
16678 {
16679 return qe_invalid;
16680 }
16681 650352 }
16682 else
16683 {
16684 528504 temp_mapscr->lens_layer = llNORMAL;
16685 }
16686
16687
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version>6)
16688 {
16689 dword bits;
16690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_igetl(&bits,f))
16691 {
16692 return qe_invalid;
16693 }
16694
16695 int32_t m;
16696 float tempfloat;
16697 word tempw;
16698 650352 temp_mapscr->ffcCountMarkDirty();
16699 650352 temp_mapscr->ffcs.clear();
16700 650352 temp_mapscr->resizeFFC(std::bit_width(bits));
16701
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 20811264 times.
21461616 for(m=0; m<32; m++)
16702 {
16703
2/2
✓ Branch 0 taken 20536512 times.
✓ Branch 1 taken 274752 times.
20811264 if((bits>>m)&1)
16704 {
16705 274752 ffcdata& tempffc = temp_mapscr->ffcs[m];
16706
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetw(&tempw,f))
16707 {
16708 return qe_invalid;
16709 }
16710 274752 tempffc.data = tempw;
16711
16712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.cset),f))
16713 {
16714 return qe_invalid;
16715 }
16716
16717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.delay),f))
16718 {
16719 return qe_invalid;
16720 }
16721
16722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version < 9)
16723 {
16724 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16725 {
16726 return qe_invalid;
16727 }
16728
16729 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16730
16731 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16732 {
16733 return qe_invalid;
16734 }
16735
16736 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16737
16738 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16739 {
16740 return qe_invalid;
16741 }
16742
16743 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16744
16745 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16746 {
16747 return qe_invalid;
16748 }
16749
16750 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16751
16752 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16753 {
16754 return qe_invalid;
16755 }
16756
16757 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16758
16759 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16760 {
16761 return qe_invalid;
16762 }
16763
16764 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16765 }
16766 else
16767 {
16768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.x),f))
16769 {
16770 return qe_invalid;
16771 }
16772
16773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.y),f))
16774 {
16775 return qe_invalid;
16776 }
16777
16778
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetzf(&(tempffc.vx),f))
16779 {
16780 return qe_invalid;
16781 }
16782
16783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.vy),f))
16784 {
16785 return qe_invalid;
16786 }
16787
16788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ax),f))
16789 {
16790 return qe_invalid;
16791 }
16792
16793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ay),f))
16794 {
16795 return qe_invalid;
16796 }
16797 }
16798
16799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.link),f))
16800 {
16801 return qe_invalid;
16802 }
16803
16804
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>7)
16805 {
16806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16807 {
16808 return qe_invalid;
16809 }
16810
16811 274752 tempffc.hit_width = (tempbyte&0x3F)+1;
16812 274752 tempffc.txsz = (tempbyte>>6)+1;
16813
16814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16815 {
16816 return qe_invalid;
16817 }
16818
16819 274752 tempffc.hit_height = (tempbyte&0x3F)+1;
16820 274752 tempffc.tysz = (tempbyte>>6)+1;
16821
16822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.flags),f))
16823 {
16824 return qe_invalid;
16825 }
16826 274752 }
16827 else
16828 {
16829 tempffc.hit_width=16;
16830 tempffc.hit_height=16;
16831 tempffc.txsz=1;
16832 tempffc.tysz=1;
16833 tempffc.flags=ffc_none;
16834 }
16835
16836 274752 tempffc.updateSolid();
16837
16838
16839
4/6
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268748 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 268748 times.
274752 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16840 {
16841 tempffc.flags|=ffc_ignoreholdup;
16842 }
16843
16844
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>9)
16845 {
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.script),f))
16847 {
16848 return qe_invalid;
16849 }
16850 274752 }
16851 else
16852 {
16853 tempffc.script=0;
16854 }
16855
16856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version>10)
16857 {
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[0]),f))
16859 {
16860 return qe_invalid;
16861 }
16862
16863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[1]),f))
16864 {
16865 return qe_invalid;
16866 }
16867
16868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[2]),f))
16869 {
16870 return qe_invalid;
16871 }
16872
16873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[3]),f))
16874 {
16875 return qe_invalid;
16876 }
16877
16878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[4]),f))
16879 {
16880 return qe_invalid;
16881 }
16882
16883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[5]),f))
16884 {
16885 return qe_invalid;
16886 }
16887
16888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[6]),f))
16889 {
16890 return qe_invalid;
16891 }
16892
16893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[7]),f))
16894 {
16895 return qe_invalid;
16896 }
16897
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16899 {
16900 return qe_invalid;
16901 }
16902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16903 {
16904 return qe_invalid;
16905 }
16906 274752 }
16907
16908
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16909 {
16910 tempffc.script = 0;
16911 for(int q = 0; q < 8; ++q)
16912 tempffc.initd[q] = 0;
16913 }
16914
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version <= 11)
16915 {
16916 fixffcs=true;
16917 }
16918 274752 }
16919 20811264 }
16920
16921 650352 temp_mapscr->shrinkToFitFFCs();
16922 650352 }
16923
16924
16925 //add in the new whistle flags
16926
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version<13)
16927 {
16928
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16929 {
16930 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16931 124 }
16932 528504 }
16933
16934 //2.55 starts here
16935
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 19 && Header->zelda_version > 0x253 )
16936 {
16937 // mapscr fields that were never used, so are now removed:
16938 // int32_t npcstrings[10];
16939 // int16_t new_items[10];
16940 // int16_t new_item_x[10];
16941 // int16_t new_item_y[10];
16942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16943 {
16944 return qe_invalid;
16945 }
16946 34408 }
16947
16948
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 20 && Header->zelda_version > 0x253 )
16949 {
16950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16951 {
16952 return qe_invalid;
16953 }
16954
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16955 {
16956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16957 {
16958 return qe_invalid;
16959 }
16960 275264 }
16961 34408 }
16962
2/2
✓ Branch 0 taken 1144448 times.
✓ Branch 1 taken 34408 times.
1178856 if ( version < 20 )
16963 {
16964 1144448 temp_mapscr->script = 0;
16965
2/2
✓ Branch 0 taken 9155584 times.
✓ Branch 1 taken 1144448 times.
10300032 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16966 1144448 }
16967
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 21 && Header->zelda_version > 0x253 )
16968 {
16969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16970 {
16971 return qe_invalid;
16972 }
16973 34408 }
16974
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 21 )
16975 {
16976 1144448 temp_mapscr->preloadscript = 0;
16977 1144448 }
16978
16979
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16980 {
16981
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16982 {
16983 return qe_invalid;
16984 }
16985
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16986 {
16987 return qe_invalid;
16988 }
16989 34408 }
16990
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 22 )
16991 {
16992 1144448 temp_mapscr->hidelayers = 0;
16993 1144448 temp_mapscr->hidescriptlayers = 0;
16994 1144448 }
16995
16996 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16997 //May be any version before 2.11. -Z
16998 /* --not the roar, the HIT SFX
16999 if ( Header->zelda_version <= 0x210 )
17000 {
17001 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17002 {
17003 temp_mapscr->bosssfx = WAV_ROAR;
17004 }
17005 }
17006 */
17007
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
17008 {
17009
1/2
✓ Branch 0 taken 4715424 times.
✗ Branch 1 not taken.
4715424 if(temp_mapscr->door[k] == dNONE)
17010 temp_mapscr->door[k] = dWALL;
17011 4715424 }
17012
17013 1178856 return 0;
17014 1178856 }
17015 1559112 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
17016 {
17017
2/2
✓ Branch 0 taken 1178856 times.
✓ Branch 1 taken 380256 times.
1559112 if(version < 23)
17018 {
17019 1178856 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
17020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(ret) return ret;
17021 1178856 }
17022 else
17023 {
17024
1/2
✓ Branch 0 taken 380256 times.
✗ Branch 1 not taken.
380256 if(!p_getc(&(temp_mapscr->valid),f))
17025 return qe_invalid;
17026
2/2
✓ Branch 0 taken 192838 times.
✓ Branch 1 taken 187418 times.
380256 if(!(temp_mapscr->valid & mVALID))
17027 {
17028 187418 int map = scrind/MAPSCRS;
17029 187418 int screen = scrind%MAPSCRS;
17030
4/6
✓ Branch 0 taken 180316 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 180316 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 180316 times.
187418 if(version > 25 && scrind > -1 && map < map_infos.size())
17031 {
17032 180316 auto const& mapinf = map_infos[map];
17033 //Empty screen, apply defaults
17034
2/2
✓ Branch 0 taken 1081896 times.
✓ Branch 1 taken 180316 times.
1262212 for(int q = 0; q < 6; ++q)
17035 {
17036 1081896 auto layermap = mapinf.autolayers[q];
17037 1081896 temp_mapscr->layermap[q] = layermap;
17038
2/2
✓ Branch 0 taken 1011119 times.
✓ Branch 1 taken 70777 times.
1081896 if(layermap)
17039 70777 temp_mapscr->layerscreen[q] = screen;
17040 1081896 }
17041 180316 temp_mapscr->color = mapinf.autopalette;
17042 180316 }
17043 187418 return 0;
17044 }
17045 uint32_t scr_has_flags;
17046
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_igetl(&scr_has_flags,f))
17047 return qe_invalid;
17048
17049
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 182380 times.
192838 if(scr_has_flags & SCRHAS_ROOMDATA)
17050 {
17051
1/2
✓ Branch 0 taken 182380 times.
✗ Branch 1 not taken.
182380 if(!p_getc(&(temp_mapscr->guy),f))
17052 return qe_invalid;
17053
2/2
✓ Branch 0 taken 182260 times.
✓ Branch 1 taken 120 times.
182380 if(version > 26)
17054 {
17055
1/2
✓ Branch 0 taken 182260 times.
✗ Branch 1 not taken.
182260 if(!p_igetl(&(temp_mapscr->guytile),f))
17056 return qe_invalid;
17057
1/2
✓ Branch 0 taken 182260 times.
✗ Branch 1 not taken.
182260 if(!p_getc(&(temp_mapscr->guycs),f))
17058 return qe_invalid;
17059
1/2
✓ Branch 0 taken 182260 times.
✗ Branch 1 not taken.
182260 if(!p_igetw(&(temp_mapscr->roomflags),f))
17060 return qe_invalid;
17061 182260 }
17062 else
17063 {
17064 120 temp_mapscr->guytile = -1; //signal to use default guy values
17065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17066
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17067 }
17068
1/2
✓ Branch 0 taken 182380 times.
✗ Branch 1 not taken.
182380 if(!p_igetw(&(temp_mapscr->str),f))
17069 return qe_invalid;
17070
1/2
✓ Branch 0 taken 182380 times.
✗ Branch 1 not taken.
182380 if(!p_getc(&(temp_mapscr->room),f))
17071 return qe_invalid;
17072
1/2
✓ Branch 0 taken 182380 times.
✗ Branch 1 not taken.
182380 if(!p_igetw(&(temp_mapscr->catchall),f))
17073 return qe_invalid;
17074 182380 }
17075
2/2
✓ Branch 0 taken 188012 times.
✓ Branch 1 taken 4826 times.
192838 if(scr_has_flags & SCRHAS_ITEM)
17076 {
17077
1/2
✓ Branch 0 taken 4826 times.
✗ Branch 1 not taken.
4826 if(!p_getc(&(temp_mapscr->item),f))
17078 return qe_invalid;
17079
1/2
✓ Branch 0 taken 4826 times.
✗ Branch 1 not taken.
4826 if(!p_getc(&(temp_mapscr->hasitem),f))
17080 return qe_invalid;
17081
1/2
✓ Branch 0 taken 4826 times.
✗ Branch 1 not taken.
4826 if(!p_getc(&(temp_mapscr->itemx),f))
17082 return qe_invalid;
17083
1/2
✓ Branch 0 taken 4826 times.
✗ Branch 1 not taken.
4826 if(!p_getc(&(temp_mapscr->itemy),f))
17084 return qe_invalid;
17085 4826 }
17086
2/2
✓ Branch 0 taken 175253 times.
✓ Branch 1 taken 17585 times.
192838 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17087 {
17088
1/2
✓ Branch 0 taken 17585 times.
✗ Branch 1 not taken.
17585 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17089 return qe_invalid;
17090 17585 }
17091
2/2
✓ Branch 0 taken 185780 times.
✓ Branch 1 taken 7058 times.
192838 if(scr_has_flags & SCRHAS_TWARP)
17092 {
17093
2/2
✓ Branch 0 taken 28232 times.
✓ Branch 1 taken 7058 times.
35290 for(int32_t i=0; i<4; i++)
17094 {
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28232 times.
28232 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17096 return qe_invalid;
17097 28232 }
17098
2/2
✓ Branch 0 taken 28232 times.
✓ Branch 1 taken 7058 times.
35290 for(int32_t i=0; i<4; i++)
17099 {
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28232 times.
28232 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17101 return qe_invalid;
17102 28232 }
17103
2/2
✓ Branch 0 taken 28232 times.
✓ Branch 1 taken 7058 times.
35290 for(int32_t i=0; i<4; i++)
17104 {
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28232 times.
28232 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17106 return qe_invalid;
17107 28232 }
17108
1/2
✓ Branch 0 taken 7058 times.
✗ Branch 1 not taken.
7058 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17109 return qe_invalid;
17110 7058 }
17111
2/2
✓ Branch 0 taken 180906 times.
✓ Branch 1 taken 11932 times.
192838 if(scr_has_flags & SCRHAS_SWARP)
17112 {
17113
2/2
✓ Branch 0 taken 47728 times.
✓ Branch 1 taken 11932 times.
59660 for(int32_t i=0; i<4; i++)
17114 {
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47728 times.
47728 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17116 return qe_invalid;
17117 47728 }
17118
2/2
✓ Branch 0 taken 47728 times.
✓ Branch 1 taken 11932 times.
59660 for(int32_t i=0; i<4; i++)
17119 {
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47728 times.
47728 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17121 return qe_invalid;
17122 47728 }
17123
2/2
✓ Branch 0 taken 47728 times.
✓ Branch 1 taken 11932 times.
59660 for(int32_t i=0; i<4; i++)
17124 {
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47728 times.
47728 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17126 return qe_invalid;
17127 47728 }
17128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11932 times.
11932 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17129 return qe_invalid;
17130
1/2
✓ Branch 0 taken 11932 times.
✗ Branch 1 not taken.
11932 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17131 return qe_invalid;
17132 11932 }
17133
2/2
✓ Branch 0 taken 180139 times.
✓ Branch 1 taken 12699 times.
192838 if(scr_has_flags & SCRHAS_WARPRET)
17134 {
17135
2/2
✓ Branch 0 taken 50796 times.
✓ Branch 1 taken 12699 times.
63495 for(int32_t i=0; i<4; i++)
17136 {
17137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50796 times.
50796 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17138 return qe_invalid;
17139 50796 }
17140
2/2
✓ Branch 0 taken 50796 times.
✓ Branch 1 taken 12699 times.
63495 for(int32_t i=0; i<4; i++)
17141 {
17142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50796 times.
50796 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17143 return qe_invalid;
17144 50796 }
17145
1/2
✓ Branch 0 taken 12699 times.
✗ Branch 1 not taken.
12699 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17146 return qe_invalid;
17147
1/2
✓ Branch 0 taken 12699 times.
✗ Branch 1 not taken.
12699 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17148 return qe_invalid;
17149 12699 }
17150
2/2
✓ Branch 0 taken 164446 times.
✓ Branch 1 taken 28392 times.
192838 if(scr_has_flags & SCRHAS_LAYERS)
17151 {
17152
2/2
✓ Branch 0 taken 170352 times.
✓ Branch 1 taken 28392 times.
198744 for(int32_t k=0; k<6; k++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170352 times.
170352 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17155 return qe_invalid;
17156 170352 }
17157
2/2
✓ Branch 0 taken 170352 times.
✓ Branch 1 taken 28392 times.
198744 for(int32_t k=0; k<6; k++)
17158 {
17159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170352 times.
170352 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17160 return qe_invalid;
17161 170352 }
17162
2/2
✓ Branch 0 taken 170352 times.
✓ Branch 1 taken 28392 times.
198744 for(int32_t k=0; k<6; k++)
17163 {
17164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170352 times.
170352 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17165 return qe_invalid;
17166 170352 }
17167
1/2
✓ Branch 0 taken 28392 times.
✗ Branch 1 not taken.
28392 if(!p_getc(&(temp_mapscr->hidelayers),f))
17168 return qe_invalid;
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28392 times.
28392 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17170 return qe_invalid;
17171 28392 }
17172
2/2
✓ Branch 0 taken 192734 times.
✓ Branch 1 taken 104 times.
192838 if(scr_has_flags & SCRHAS_MAZE)
17173 {
17174
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17175 {
17176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17177 return qe_invalid;
17178 416 }
17179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17180 return qe_invalid;
17181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17182 {
17183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17184 return qe_invalid;
17185 104 }
17186 104 }
17187
2/2
✓ Branch 0 taken 147844 times.
✓ Branch 1 taken 44994 times.
192838 if(scr_has_flags & SCRHAS_D_S_U)
17188 {
17189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147844 times.
147844 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17190 return qe_invalid;
17191
2/2
✓ Branch 0 taken 591376 times.
✓ Branch 1 taken 147844 times.
739220 for(int32_t k=0; k<4; k++)
17192 {
17193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 591376 times.
591376 if(!p_getc(&(temp_mapscr->door[k]),f))
17194 return qe_invalid;
17195
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 591016 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
591376 if(version < 29 && temp_mapscr->door[k] == dNONE)
17196 temp_mapscr->door[k] = dWALL;
17197 591376 }
17198
17199
1/2
✓ Branch 0 taken 147844 times.
✗ Branch 1 not taken.
147844 if(!p_getc(&(temp_mapscr->stairx),f))
17200 return qe_invalid;
17201
17202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147844 times.
147844 if(!p_getc(&(temp_mapscr->stairy),f))
17203 return qe_invalid;
17204
1/2
✓ Branch 0 taken 147844 times.
✗ Branch 1 not taken.
147844 if(!p_igetw(&(temp_mapscr->undercombo),f))
17205 return qe_invalid;
17206
1/2
✓ Branch 0 taken 147844 times.
✗ Branch 1 not taken.
147844 if(!p_getc(&(temp_mapscr->undercset),f))
17207 return qe_invalid;
17208 147844 }
17209
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 34506 times.
44994 else if(version < 29)
17210 {
17211
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17212 41952 temp_mapscr->door[k] = dWALL;
17213 10488 }
17214
2/2
✓ Branch 0 taken 178045 times.
✓ Branch 1 taken 14793 times.
192838 if(scr_has_flags & SCRHAS_FLAGS)
17215 {
17216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14793 times.
14793 if(!p_getc(&(temp_mapscr->flags),f))
17217 return qe_invalid;
17218
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags2),f))
17219 return qe_invalid;
17220
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags3),f))
17221 return qe_invalid;
17222
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags4),f))
17223 return qe_invalid;
17224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14793 times.
14793 if(!p_getc(&(temp_mapscr->flags5),f))
17225 return qe_invalid;
17226
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags6),f))
17227 return qe_invalid;
17228
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags7),f))
17229 return qe_invalid;
17230
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags8),f))
17231 return qe_invalid;
17232
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags9),f))
17233 return qe_invalid;
17234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14793 times.
14793 if(!p_getc(&(temp_mapscr->flags10),f))
17235 return qe_invalid;
17236
1/2
✓ Branch 0 taken 14793 times.
✗ Branch 1 not taken.
14793 if(!p_getc(&(temp_mapscr->flags11),f))
17237 return qe_invalid;
17238 14793 }
17239
2/2
✓ Branch 0 taken 179263 times.
✓ Branch 1 taken 13575 times.
192838 if(scr_has_flags & SCRHAS_ENEMY)
17240 {
17241
2/2
✓ Branch 0 taken 135750 times.
✓ Branch 1 taken 13575 times.
149325 for(int32_t k=0; k<10; k++)
17242 {
17243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135750 times.
135750 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17244 return qe_invalid;
17245
1/2
✓ Branch 0 taken 135750 times.
✗ Branch 1 not taken.
135750 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17246 temp_mapscr->enemy[k] = 0;
17247 135750 }
17248
1/2
✓ Branch 0 taken 13575 times.
✗ Branch 1 not taken.
13575 if(!p_getc(&(temp_mapscr->pattern),f))
17249 return qe_invalid;
17250 13575 }
17251
2/2
✓ Branch 0 taken 153508 times.
✓ Branch 1 taken 39330 times.
192838 if(scr_has_flags & SCRHAS_CARRY)
17252 {
17253
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 153186 times.
153508 if(version < 34)
17254 {
17255 word tmpw;
17256
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(!p_igetw(&tmpw,f))
17257 return qe_invalid;
17258 322 temp_mapscr->noreset = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED;
17259
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(!p_igetw(&tmpw,f))
17260 return qe_invalid;
17261 644 temp_mapscr->nocarry = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED |
17262 322 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17263 322 }
17264 else
17265 {
17266
1/2
✓ Branch 0 taken 153186 times.
✗ Branch 1 not taken.
153186 if(!p_igetl(&(temp_mapscr->noreset),f))
17267 return qe_invalid;
17268
1/2
✓ Branch 0 taken 153186 times.
✗ Branch 1 not taken.
153186 if(!p_igetl(&(temp_mapscr->nocarry),f))
17269 return qe_invalid;
17270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153186 times.
153186 if(!p_igetl(&(temp_mapscr->exstate_reset),f))
17271 return qe_invalid;
17272
1/2
✓ Branch 0 taken 153186 times.
✗ Branch 1 not taken.
153186 if(!p_igetl(&(temp_mapscr->exstate_carry),f))
17273 return qe_invalid;
17274 }
17275
1/2
✓ Branch 0 taken 153508 times.
✗ Branch 1 not taken.
153508 if(!p_getc(&(temp_mapscr->nextmap),f))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 153508 times.
✗ Branch 1 not taken.
153508 if(!p_getc(&(temp_mapscr->nextscr),f))
17278 return qe_invalid;
17279 153508 }
17280 else
17281 {
17282
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 38606 times.
39330 if(version < 34)
17283 {
17284 38606 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
17285 38606 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
17286 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17287 38606 }
17288 }
17289
2/2
✓ Branch 0 taken 192117 times.
✓ Branch 1 taken 721 times.
192838 if(scr_has_flags & SCRHAS_SCRIPT)
17290 {
17291
1/2
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
721 if(!p_igetw(&(temp_mapscr->script),f))
17292 return qe_invalid;
17293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if(!p_getc(&(temp_mapscr->preloadscript),f))
17294 return qe_invalid;
17295
2/2
✓ Branch 0 taken 5768 times.
✓ Branch 1 taken 721 times.
6489 for ( int32_t q = 0; q < 8; q++ )
17296 {
17297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5768 times.
5768 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17298 return qe_invalid;
17299 5768 }
17300 721 }
17301
2/2
✓ Branch 0 taken 153318 times.
✓ Branch 1 taken 39520 times.
192838 if(scr_has_flags & SCRHAS_SECRETS)
17302 {
17303
2/2
✓ Branch 0 taken 5058560 times.
✓ Branch 1 taken 39520 times.
5098080 for(int32_t k=0; k<128; k++)
17304 {
17305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058560 times.
5058560 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17306 return qe_invalid;
17307 5058560 }
17308
2/2
✓ Branch 0 taken 5058560 times.
✓ Branch 1 taken 39520 times.
5098080 for(int32_t k=0; k<128; k++)
17309 {
17310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058560 times.
5058560 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17311 return qe_invalid;
17312 5058560 }
17313
2/2
✓ Branch 0 taken 5058560 times.
✓ Branch 1 taken 39520 times.
5098080 for(int32_t k=0; k<128; k++)
17314 {
17315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058560 times.
5058560 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17316 return qe_invalid;
17317 5058560 }
17318 39520 }
17319
2/2
✓ Branch 0 taken 74243 times.
✓ Branch 1 taken 118595 times.
192838 if(scr_has_flags & SCRHAS_COMBOFLAG)
17320 {
17321
2/2
✓ Branch 0 taken 20872720 times.
✓ Branch 1 taken 118595 times.
20991315 for(int32_t k=0; k<176; ++k)
17322 {
17323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20872720 times.
20872720 if(!p_igetw(&(temp_mapscr->data[k]),f))
17324 return qe_invalid;
17325 20872720 }
17326
2/2
✓ Branch 0 taken 20872720 times.
✓ Branch 1 taken 118595 times.
20991315 for(int32_t k=0; k<176; ++k)
17327 {
17328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20872720 times.
20872720 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17329 return qe_invalid;
17330 20872720 }
17331
2/2
✓ Branch 0 taken 20872720 times.
✓ Branch 1 taken 118595 times.
20991315 for(int32_t k=0; k<176; ++k)
17332 {
17333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20872720 times.
20872720 if(!p_getc(&(temp_mapscr->cset[k]),f))
17334 return qe_invalid;
17335 20872720 }
17336 118595 }
17337
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(scr_has_flags & SCRHAS_MISC)
17338 {
17339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192838 times.
192838 if(!p_igetw(&(temp_mapscr->color),f))
17340 return qe_invalid;
17341
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_getc(&(temp_mapscr->csensitive),f))
17342 return qe_invalid;
17343
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_getc(&(temp_mapscr->oceansfx),f))
17344 return qe_invalid;
17345
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_getc(&(temp_mapscr->bosssfx),f))
17346 return qe_invalid;
17347
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_getc(&(temp_mapscr->secretsfx),f))
17348 return qe_invalid;
17349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192838 times.
192838 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17350 return qe_invalid;
17351
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17352 return qe_invalid;
17353
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17354 return qe_invalid;
17355
1/2
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
192838 if(!p_getc(&(temp_mapscr->lens_layer),f))
17356 return qe_invalid;
17357
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 182260 times.
192838 if(version > 27)
17358 {
17359
1/2
✓ Branch 0 taken 182260 times.
✗ Branch 1 not taken.
182260 if(!p_getc(&(temp_mapscr->lens_show),f))
17360 return qe_invalid;
17361
1/2
✓ Branch 0 taken 182260 times.
✗ Branch 1 not taken.
182260 if(!p_getc(&(temp_mapscr->lens_hide),f))
17362 return qe_invalid;
17363 182260 }
17364 192838 }
17365 else
17366 {
17367 temp_mapscr->screen_midi = -1;
17368 temp_mapscr->csensitive = 1;
17369 }
17370 //FFC
17371 192838 bool old_ff = version < 25;
17372 192838 dword bits = 0;
17373 192838 word numffc = 32;
17374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192838 times.
192838 if(old_ff)
17375 {
17376 if(!p_igetl(&bits,f))
17377 return qe_invalid;
17378 }
17379 else
17380 {
17381
2/4
✓ Branch 0 taken 192838 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192838 times.
192838 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17382 return qe_invalid;
17383 }
17384
17385 192838 temp_mapscr->ffcCountMarkDirty();
17386 192838 temp_mapscr->ffcs.clear();
17387 192838 temp_mapscr->resizeFFC(numffc);
17388
17389 byte tempbyte;
17390 word tempw;
17391
4/6
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 192665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
✓ Branch 4 taken 173 times.
✗ Branch 5 not taken.
192838 static ffcdata nil_ffc;
17392
2/2
✓ Branch 0 taken 1995904 times.
✓ Branch 1 taken 192838 times.
2188742 for(word m = 0; m < numffc; ++m)
17393 {
17394
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1995904 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1995904 if(old_ff && !(bits & (1<<m))) continue;
17395
17396
1/2
✓ Branch 0 taken 1995904 times.
✗ Branch 1 not taken.
1995904 ffcdata& tempffc = (m < MAXFFCS)
17397 1995904 ? temp_mapscr->ffcs[m]
17398 : nil_ffc; //sanity
17399
17400
1/2
✓ Branch 0 taken 1995904 times.
✗ Branch 1 not taken.
1995904 if(!p_igetw(&tempw,f))
17401 return qe_invalid;
17402
3/4
✓ Branch 0 taken 1995904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27819 times.
✓ Branch 3 taken 1968085 times.
1995904 if(!old_ff && !tempw) //empty ffc, nothing more to load
17403 1968085 continue;
17404 27819 tempffc.data = tempw;
17405
17406
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_getc(&(tempffc.cset),f))
17407 return qe_invalid;
17408
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetw(&(tempffc.delay),f))
17409 return qe_invalid;
17410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(!p_igetzf(&(tempffc.x),f))
17411 return qe_invalid;
17412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(!p_igetzf(&(tempffc.y),f))
17413 return qe_invalid;
17414
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetzf(&(tempffc.vx),f))
17415 return qe_invalid;
17416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(!p_igetzf(&(tempffc.vy),f))
17417 return qe_invalid;
17418
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetzf(&(tempffc.ax),f))
17419 return qe_invalid;
17420
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetzf(&(tempffc.ay),f))
17421 return qe_invalid;
17422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(!p_getc(&(tempffc.link),f))
17423 return qe_invalid;
17424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(version < 24)
17425 {
17426 if(!p_getc(&tempbyte,f))
17427 return qe_invalid;
17428 tempffc.hit_width = (tempbyte&0x3F)+1;
17429 tempffc.txsz = (tempbyte>>6)+1;
17430 if(!p_getc(&tempbyte,f))
17431 return qe_invalid;
17432 tempffc.hit_height = (tempbyte&0x3F)+1;
17433 tempffc.tysz = (tempbyte>>6)+1;
17434 }
17435 else
17436 {
17437
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetl(&(tempffc.hit_width),f))
17438 return qe_invalid;
17439
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetl(&(tempffc.hit_height),f))
17440 return qe_invalid;
17441
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_getc(&(tempffc.txsz),f))
17442 return qe_invalid;
17443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(!p_getc(&(tempffc.tysz),f))
17444 return qe_invalid;
17445 }
17446
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(!p_igetl(&(tempffc.flags),f))
17447 return qe_invalid;
17448 27819 tempffc.updateSolid();
17449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27819 times.
27819 if(!p_igetw(&(tempffc.script),f))
17450 return qe_invalid;
17451
2/2
✓ Branch 0 taken 222552 times.
✓ Branch 1 taken 27819 times.
250371 for(auto q = 0; q < 8; ++q)
17452 {
17453
1/2
✓ Branch 0 taken 222552 times.
✗ Branch 1 not taken.
222552 if(!p_igetl(&(tempffc.initd[q]),f))
17454 return qe_invalid;
17455 222552 }
17456
2/2
✓ Branch 0 taken 7633 times.
✓ Branch 1 taken 20186 times.
27819 if(version < 33)
17457 {
17458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7633 times.
7633 if(!p_getc(&(tempbyte),f))
17459 return qe_invalid;
17460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7633 times.
7633 if(!p_getc(&(tempbyte),f))
17461 return qe_invalid;
17462 7633 }
17463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20186 times.
20186 else if(!p_getc(&(tempffc.layer),f))
17464 return qe_invalid;
17465
17466
1/2
✓ Branch 0 taken 27819 times.
✗ Branch 1 not taken.
27819 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17467 {
17468 tempffc.script = 0;
17469 for(int q = 0; q < 8; ++q)
17470 tempffc.initd[q] = 0;
17471 }
17472 27819 }
17473 //END FFC
17474
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 154341 times.
192838 if(version > 29)
17475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154341 times.
154341 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17476 return qe_invalid;
17477
17478
4/4
✓ Branch 0 taken 67630 times.
✓ Branch 1 taken 125208 times.
✓ Branch 2 taken 67528 times.
✓ Branch 3 taken 102 times.
192838 if (version >= 35 && (temp_mapscr->flags10 & fSCREEN_GRAVITY))
17479 {
17480
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_gravity, f))
17481 return qe_invalid;
17482
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_terminal_v, f))
17483 return qe_invalid;
17484 102 }
17485 }
17486
17487 1371694 temp_mapscr->shrinkToFitFFCs();
17488
17489 1371694 return 0;
17490 1559112 }
17491
17492 493 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17493 {
17494
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17495 493 int32_t screen=0;
17496
17497 493 word version=0;
17498 dword dummy;
17499 int32_t screens_to_read;
17500
17501 493 mapscr temp_mapscr{};
17502 word temp_map_count;
17503 dword section_size;
17504
17505
5/6
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
493 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17506 {
17507 18 screens_to_read=MAPSCRS192b136;
17508 18 }
17509 else
17510 {
17511 475 screens_to_read=MAPSCRS;
17512 }
17513
17514
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 if(Header->zelda_version > 0x192)
17515 {
17516 //section version info
17517
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&version,f))
17518 {
17519 return qe_invalid;
17520 }
17521
17522
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (version > V_MAPS)
17523 return qe_version;
17524
17525 469 FFCore.quest_format[vMaps] = version;
17526
17527
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&dummy,f))
17528 {
17529 return qe_invalid;
17530 }
17531
17532 //section size
17533
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetl(&section_size,f))
17534 {
17535 return qe_invalid;
17536 }
17537
17538 //finally... section data
17539
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&temp_map_count,f))
17540 {
17541 return 5;
17542 }
17543 469 }
17544 else
17545 {
17546 24 temp_map_count=map_count;
17547 }
17548
17549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
493 if (temp_map_count > MAXMAPS)
17550 {
17551 return qe_invalid;
17552 }
17553
17554
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 1 times.
493 if (!should_skip)
17555 {
17556 492 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17557 492 TheMaps.clear();
17558
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 TheMaps.resize(_mapsSize);
17559 492 old_combo_pages.clear();
17560
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 old_combo_pages.resize(_mapsSize);
17561 492 map_infos.clear();
17562
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 map_infos.resize(temp_map_count);
17563
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 165 times.
492 if(version >= 31)
17564 165 Regions = {};
17565 492 }
17566
17567
4/4
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 12882 times.
✓ Branch 2 taken 12882 times.
✓ Branch 3 taken 493 times.
13375 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17568 {
17569 12882 byte valid=1;
17570
2/2
✓ Branch 0 taken 4209 times.
✓ Branch 1 taken 8673 times.
12882 if(version > 22)
17571 {
17572
2/4
✓ Branch 0 taken 4209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4209 times.
✗ Branch 3 not taken.
4209 if(!p_getc(&valid,f))
17573 return qe_invalid;
17574 4209 }
17575
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 11469 times.
12882 if(valid)
17576 {
17577
2/2
✓ Branch 0 taken 8803 times.
✓ Branch 1 taken 2666 times.
11469 if (version > 25)
17578 {
17579 2666 auto& mapinf = map_infos[i];
17580
2/2
✓ Branch 0 taken 15996 times.
✓ Branch 1 taken 2666 times.
18662 for(int q = 0; q < 6; ++q)
17581 {
17582
2/4
✓ Branch 0 taken 15996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15996 times.
✗ Branch 3 not taken.
15996 if(!p_igetw(&mapinf.autolayers[q],f))
17583 return qe_invalid;
17584 15996 }
17585
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 1734 times.
2666 if (version >= 36)
17586
2/4
✓ Branch 0 taken 932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 932 times.
✗ Branch 3 not taken.
932 if(!p_igetw(&mapinf.autopalette,f))
17587 return qe_invalid;
17588 2666 }
17589
17590
2/2
✓ Branch 0 taken 9245 times.
✓ Branch 1 taken 2224 times.
11469 if (version >= 31)
17591 {
17592 static regions_data tmp_rd;
17593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2224 times.
2224 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17594
2/2
✓ Branch 0 taken 17792 times.
✓ Branch 1 taken 2224 times.
20016 for(int32_t j=0; j<8; j++)
17595 {
17596
2/2
✓ Branch 0 taken 142336 times.
✓ Branch 1 taken 17792 times.
160128 for(int32_t k=0; k<8; k++)
17597 {
17598
2/4
✓ Branch 0 taken 142336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142336 times.
✗ Branch 3 not taken.
142336 if(!p_getc(&rd.region_ids[j][k],f))
17599 {
17600 return qe_invalid;
17601 }
17602 142336 }
17603 17792 }
17604 2224 }
17605 11469 }
17606
2/2
✓ Branch 0 taken 1751280 times.
✓ Branch 1 taken 12882 times.
1764162 for(int32_t j=0; j<screens_to_read; j++)
17607 {
17608 1751280 screen=i*MAPSCRS+j;
17609
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1751008 times.
1751280 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17610 1751280 scr->map = i;
17611 1751280 scr->screen = j;
17612
2/2
✓ Branch 0 taken 1559112 times.
✓ Branch 1 taken 192168 times.
1751280 if(valid)
17613
1/2
✓ Branch 0 taken 1559112 times.
✗ Branch 1 not taken.
1559112 readmapscreen(f, Header, scr, version, screen);
17614
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 else if (!should_skip)
17615
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 clear_screen(scr);
17616 1751280 }
17617
17618
2/2
✓ Branch 0 taken 12880 times.
✓ Branch 1 taken 2 times.
12882 if (should_skip)
17619 2 continue;
17620
17621
5/6
✓ Branch 0 taken 12712 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12694 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17622 {
17623 168 int32_t index = (i*MAPSCRS+132);
17624
17625
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17626
17627 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17628 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17629 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17630
17631
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17632 {
17633 504 screen=i*MAPSCRS+j;
17634
17635
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17636 504 TheMaps[screen].valid = mVERSION;
17637 504 TheMaps[screen].screen_midi = -1;
17638 504 TheMaps[screen].csensitive = 1;
17639 504 }
17640 168 }
17641
17642
5/6
✓ Branch 0 taken 12712 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12694 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17643 {
17644
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17645 {
17646 22848 screen=i*MAPSCRS+j;
17647
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17648
17649
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17650 {
17651
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17652
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17653
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17654 2924544 }
17655 22848 }
17656 168 }
17657 12880 }
17658 493 map_count = temp_map_count;
17659 493 return 0;
17660 493 }
17661
17662
17663 9214404 void update_combo(newcombo& cmb, word section_version)
17664 {
17665
2/2
✓ Branch 0 taken 1532385 times.
✓ Branch 1 taken 7682019 times.
9214404 if(section_version < 40)
17666 {
17667
3/3
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 45418 times.
✓ Branch 2 taken 7631457 times.
7682019 switch(cmb.type)
17668 {
17669 case cWATER: case cSHALLOWWATER:
17670 45418 cmb.attribytes[6] = iwRipples;
17671 45418 break;
17672 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17673 5144 cmb.attribytes[6] = iwTallGrass;
17674 5144 break;
17675 }
17676 7682019 }
17677
2/2
✓ Branch 0 taken 1184954 times.
✓ Branch 1 taken 8029450 times.
9214404 if(section_version < 49)
17678 {
17679
4/4
✓ Branch 0 taken 7994679 times.
✓ Branch 1 taken 34771 times.
✓ Branch 2 taken 15455 times.
✓ Branch 3 taken 7979224 times.
8029450 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17680 50226 cmb.sfx_landing = WAV_ZN1SPLASH;
17681 8029450 }
17682 9214404 }
17683 288 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17684 {
17685
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 24 times.
288 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17686 byte tempbyte;
17687
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17688 {
17689 287 reset_all_combo_animations();
17690 287 init_combo_classes();
17691 287 }
17692
17693 // combos
17694 288 word combos_used=0;
17695 int32_t dummy;
17696 byte padding;
17697 288 newcombo temp_combo;
17698
17699
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17700
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17701
1/2
✓ Branch 0 taken 18735360 times.
✗ Branch 1 not taken.
18735647 combobuf[q].clear();
17702
17703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(version < 0x174)
17704 {
17705 combos_used=1024;
17706 }
17707
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 18 times.
288 else if(version < 0x191)
17708 {
17709 18 combos_used=2048;
17710 18 }
17711 else
17712 {
17713
2/4
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
270 if(!p_igetw(&combos_used,f))
17714 {
17715 return qe_invalid;
17716 }
17717 }
17718
17719 //finally... section data
17720
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 288 times.
7547291 for(int32_t i=0; i<combos_used; i++)
17721 {
17722
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_combo.clear();
17723
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17724 7547003 int32_t temp_trigflags[6] = {0};
17725
17726
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if ( section_version >= 11 )
17727 {
17728
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17729 {
17730 return qe_invalid;
17731 }
17732 202968 }
17733 else
17734 {
17735
2/4
✓ Branch 0 taken 7344035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7344035 times.
✗ Branch 3 not taken.
7344035 if(!p_igetw(&temp_combo.tile,f))
17736 {
17737 return qe_invalid;
17738 }
17739 }
17740 7547003 temp_combo.o_tile = temp_combo.tile;
17741
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.flip,f))
17742 {
17743 return qe_invalid;
17744 }
17745
17746
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.walk,f))
17747 {
17748 return qe_invalid;
17749 }
17750
17751
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.type,f))
17752 {
17753 return qe_invalid;
17754 }
17755
17756
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.csets,f))
17757 {
17758 return qe_invalid;
17759 }
17760
17761
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7477229 times.
7547003 if(version < 0x193)
17762 {
17763
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17764 return qe_invalid;
17765
17766
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17767 return qe_invalid;
17768
17769
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17770 {
17771
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17772 {
17773 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17774 {
17775 if(!p_getc(&padding,f))
17776 return qe_invalid;
17777 }
17778 }
17779 36864 }
17780 69774 }
17781
2/2
✓ Branch 0 taken 7510139 times.
✓ Branch 1 taken 36864 times.
7547003 if(version >= 0x192)
17782 {
17783
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.frames,f))
17784 return qe_invalid;
17785
17786
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.speed,f))
17787 return qe_invalid;
17788
17789
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_igetw(&temp_combo.nextcombo,f))
17790 return qe_invalid;
17791
17792
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.nextcset,f))
17793 return qe_invalid;
17794
17795 //Base flag
17796
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=3)
17797
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.flag,f))
17798 return qe_invalid;
17799
17800
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=4)
17801 {
17802
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanim,f))
17803 return qe_invalid;
17804
17805
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_igetw(&temp_combo.nexttimer,f))
17806 return qe_invalid;
17807 4621731 }
17808
17809
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=5)
17810
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanimy,f))
17811 return qe_invalid;
17812
17813
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=6)
17814 {
17815
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.animflags,f))
17816 return qe_invalid;
17817
17818
1/2
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
4621731 if(section_version == 6)
17819 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17820 4621731 }
17821
17822
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=8) //combo Attributes[4] and userflags.
17823 {
17824
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17825
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17826 return qe_invalid;
17827
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17828 return qe_invalid;
17829
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17830
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17831 return qe_invalid;
17832 202968 }
17833
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=10) //combo trigger flags
17834 {
17835
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17836
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigflags[q],f))
17837 return qe_invalid;
17838 202968 }
17839
1/2
✓ Branch 0 taken 7307171 times.
✗ Branch 1 not taken.
7307171 else if(section_version==9) //combo trigger flags, V9 only had two indices
17840 {
17841 for ( int32_t q = 0; q < 2; q++ )
17842 if(!p_igetl(&temp_trigflags[q],f))
17843 return qe_invalid;
17844 }
17845
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 9)
17846
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17847 return qe_invalid;
17848
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 22)
17849
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17850 return qe_invalid;
17851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 24)
17852 {
17853 if(!p_getc(&temp_trigger.triggeritem,f))
17854 return qe_invalid;
17855 if(!p_getc(&tempbyte, f))
17856 return qe_invalid;
17857 temp_trigger.trigtimer = tempbyte;
17858 }
17859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 25)
17860 if(!p_getc(&temp_trigger.trigsfx,f))
17861 return qe_invalid;
17862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 27)
17863 if(!p_igetl(&temp_trigger.trigchange,f))
17864 return qe_invalid;
17865
17866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 29)
17867 {
17868 if(!p_igetw(&temp_trigger.trigprox,f))
17869 return qe_invalid;
17870 if(!p_getc(&tempbyte,f))
17871 return qe_invalid;
17872 temp_trigger.trigctr = tempbyte;
17873 if(!p_igetl(&temp_trigger.trigctramnt,f))
17874 return qe_invalid;
17875 }
17876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 30)
17877 if(!p_getc(&temp_trigger.triglbeam,f))
17878 return qe_invalid;
17879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 31)
17880 {
17881 if(!p_getc(&temp_trigger.trigcschange,f))
17882 return qe_invalid;
17883 if(!p_igetw(&temp_trigger.spawnitem,f))
17884 return qe_invalid;
17885 if(!p_igetw(&temp_trigger.spawnenemy,f))
17886 return qe_invalid;
17887 if(!p_getc(&temp_trigger.exstate,f))
17888 return qe_invalid;
17889 if(!p_igetl(&temp_trigger.spawnip,f))
17890 return qe_invalid;
17891 if(!p_getc(&temp_trigger.trigcopycat,f))
17892 return qe_invalid;
17893 }
17894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 32)
17895 if(!p_getc(&temp_trigger.trigcooldown,f))
17896 return qe_invalid;
17897
17898
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=12) //combo label
17899 {
17900 char label[12];
17901 202968 label[11] = '\0';
17902
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17903
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17904 return qe_invalid;
17905
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17906 202968 }
17907
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=13) //attribytes[4]
17908
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17909
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17910 202968 return qe_invalid;
17911 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17912 * This fixes a poor implementation of a ->next flag bug thing.
17913 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17914 * there was a version bump a few weeks before a change that broke stuff.
17915 */
17916
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if (section_version >= 13 && section_version < 21)
17917 {
17918 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17919 }
17920 //combo scripts
17921
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=14)
17922 {
17923
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17924 return qe_invalid;
17925
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17926
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17927 return qe_invalid;
17928 202968 }
17929
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=15)
17930 {
17931
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17932
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17933
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17934
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17935 202968 }
17936
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=17) //attribytes[4]
17937 {
17938
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17939
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17940 return qe_invalid;
17941
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17942
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17943 return qe_invalid;
17944 202968 }
17945
17946
2/2
✓ Branch 0 taken 7477229 times.
✓ Branch 1 taken 32910 times.
7510139 if(version < 0x193)
17947
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17948
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17949 32910 return qe_invalid;
17950 7510139 }
17951
17952 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17953
3/6
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4621731 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7547003 if((version < 0x211)||((version == 0x211)&&(build<7)))
17954 {
17955
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17956 {
17957
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17958 {
17959 case 130:
17960 temp_combo.tile = 132;
17961 break;
17962
17963 case 131:
17964 temp_combo.tile = 133;
17965 break;
17966
17967 case 132:
17968 temp_combo.tile = 130;
17969 break;
17970
17971 case 133:
17972 temp_combo.tile = 131;
17973 break;
17974 }
17975 39936 }
17976 2925272 }
17977
17978
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 15)
17979 7344035 temp_combo.o_tile = temp_combo.tile;
17980
17981
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version<18) //upper bits for .walk
17982 7344035 temp_combo.walk |= 0xF0;
17983
17984
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 19)
17985
2/2
✓ Branch 0 taken 29376140 times.
✓ Branch 1 taken 7344035 times.
36720175 for(int32_t q = 0; q < 4; ++q)
17986 36720175 temp_combo.attributes[q] *= 10000L;
17987
17988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 23)
17989 {
17990
2/2
✓ Branch 0 taken 15235 times.
✓ Branch 1 taken 7531768 times.
7547003 switch(temp_combo.type) //TRIGFLAG_CMBTYPEFX now required for combotype-specific effects
17991 {
17992 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17993 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17994 case cTRIGGERGENERIC: case cCSWITCH:
17995 15235 temp_trigflags[TRIGFLAG_CMBTYPEFX/32] |= 1<<(TRIGFLAG_CMBTYPEFX%32);
17996 15235 }
17997 7547003 }
17998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 25)
17999 {
18000
2/2
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 7519607 times.
7547003 switch(temp_combo.type)
18001 {
18002 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27396 times.
27396 if(!(temp_combo.usrflags & cflag3))
18004 27396 temp_combo.attribytes[3] = WAV_DOOR;
18005 27396 temp_combo.usrflags &= ~cflag3;
18006 27396 break;
18007 }
18008 7547003 }
18009
18010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 26)
18011
2/2
✓ Branch 0 taken 7545882 times.
✓ Branch 1 taken 1121 times.
7548124 if(temp_combo.type == cARMOS)
18012
1/2
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
1121 if(temp_combo.usrflags & cflag1)
18013 temp_combo.usrflags |= cflag3;
18014
18015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 27)
18016 {
18017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(temp_trigflags[0] & 0x00040000) //'next'
18018 temp_trigger.trigchange = 1;
18019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 else if(temp_trigflags[0] & 0x00080000) //'prev'
18020 temp_trigger.trigchange = -1;
18021 7547003 else temp_trigger.trigchange = 0;
18022 7547003 temp_trigflags[0] &= ~(0x00040000|0x00080000);
18023 7547003 }
18024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 28)
18025 {
18026
2/2
✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 7531491 times.
7547003 switch(temp_combo.type)
18027 {
18028 case cLOCKBLOCK: case cLOCKEDCHEST:
18029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15512 times.
15512 if(temp_combo.usrflags & cflag7)
18030 temp_combo.usrflags |= cflag8;
18031 15512 else temp_combo.usrflags &= ~cflag8;
18032 15512 temp_combo.usrflags &= ~cflag7;
18033 15512 break;
18034 }
18035
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 7546245 times.
7547003 switch(temp_combo.type)
18036 {
18037 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18038 758 temp_combo.attrishorts[2] = -1;
18039 758 temp_combo.usrflags |= cflag7;
18040 758 break;
18041 }
18042 7547003 }
18043
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 20)
18044 {
18045 7344035 temp_combo.genflags = 0;
18046
2/2
✓ Branch 0 taken 143987 times.
✓ Branch 1 taken 7200048 times.
7344035 switch(temp_combo.type)
18047 {
18048 case cPUSH_WAIT: case cPUSH_HEAVY:
18049 case cPUSH_HW: case cL_STATUE:
18050 case cR_STATUE: case cPUSH_HEAVY2:
18051 case cPUSH_HW2: case cPOUND:
18052 case cC_STATUE: case cMIRROR:
18053 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18054 case cMAGICPRISM: case cMAGICPRISM4:
18055 case cMAGICSPONGE: case cEYEBALL_A:
18056 case cEYEBALL_B: case cEYEBALL_4:
18057 case cBUSH: case cFLOWERS:
18058 case cLOCKBLOCK: case cLOCKBLOCK2:
18059 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18060 case cCHEST: case cCHEST2:
18061 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18062 case cBOSSCHEST: case cBOSSCHEST2:
18063 case cBUSHNEXT: case cBUSHTOUCHY:
18064 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18065 case cSIGNPOST: case cCSWITCHBLOCK:
18066 case cTORCH: case cTRIGGERGENERIC:
18067
1/2
✓ Branch 0 taken 143987 times.
✗ Branch 1 not taken.
143987 if(temp_combo.usrflags & cflag16)
18068 {
18069 temp_combo.genflags |= cflag1;
18070 temp_combo.usrflags &= ~cflag16;
18071 }
18072 143987 break;
18073 }
18074 7344035 }
18075
18076
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_trigger.trigger_flags.clear();
18077
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 1449024576 times.
1456571579 for(size_t q = 0; q < 32*6; ++q)
18078 {
18079 1449024576 auto ind = q/32;
18080 1449024576 auto bit = 1<<(q%32);
18081
2/2
✓ Branch 0 taken 1449008300 times.
✓ Branch 1 taken 16276 times.
1449024576 if(temp_trigflags[ind] & bit)
18082
1/2
✓ Branch 0 taken 16276 times.
✗ Branch 1 not taken.
16276 temp_trigger.trigger_flags.set(q, true);
18083 1449024576 }
18084
18085
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15274 times.
✓ Branch 3 taken 7531729 times.
7547003 if(temp_trigger.is_blank())
18086 7531729 temp_combo.triggers.clear();
18087
18088 7547003 update_combo(temp_combo, section_version);
18089
18090
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7532084 times.
✓ Branch 3 taken 14919 times.
7547003 if(i>=start_combo && !should_skip)
18091 {
18092
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18093 {
18094 temp_combo.script = 0;
18095 for(int q = 0; q < 8; ++q)
18096 temp_combo.initd[q] = 0;
18097 }
18098
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 combobuf[i] = temp_combo;
18099 7532084 }
18100 7547003 }
18101
18102
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 1 times.
288 if (should_skip)
18103 1 return 0;
18104
18105
5/6
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
287 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18106 {
18107
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18108 {
18109
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18110 {
18111 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18112 215 }
18113 1501440 }
18114 23 }
18115
18116 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18117
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
287 if(version == 0x210 && get_app_id() != App::zquest)
18118 {
18119
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18120
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
18121 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18122 59 }
18123
18124
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<7)
18125 {
18126
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18127 {
18128
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
18129 {
18130 case cSLASH:
18131 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18132 853 break;
18133
18134 case cSLASHITEM:
18135 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18136 791 break;
18137
18138 case cBUSH:
18139 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18140 603 break;
18141
18142 case cFLOWERS:
18143 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18144 174 break;
18145
18146 case cTALLGRASS:
18147 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18148 531 break;
18149
18150 case cSLASHNEXT:
18151 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18152 break;
18153
18154 case cSLASHNEXTITEM:
18155 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18156 break;
18157
18158 case cBUSHNEXT:
18159 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18160 break;
18161 }
18162 5352960 }
18163 82 }
18164
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
287 if (section_version < 16)
18165 {
18166
2/2
✓ Branch 0 taken 18408960 times.
✓ Branch 1 taken 282 times.
18409242 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18167 {
18168
2/2
✓ Branch 0 taken 18380119 times.
✓ Branch 1 taken 28841 times.
18408960 if (combobuf[tmpcounter].type == cWATER)
18169 {
18170 28841 combobuf[tmpcounter].attributes[0] = 40000L;
18171 28841 }
18172 18408960 }
18173 282 }
18174
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 3 times.
287 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18175 {
18176 3 combobuf[0].walk = 0xF0;
18177 3 combobuf[0].type = 0;
18178 3 combobuf[0].flag = 0;
18179 3 }
18180
18181 //Now for the new combo alias reset
18182
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<2)
18183 {
18184
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18185 {
18186 671744 combo_aliases[j].width = 0;
18187 671744 combo_aliases[j].height = 0;
18188 671744 combo_aliases[j].layermask = 0;
18189
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18190
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18191 671744 }
18192 82 }
18193
18194
18195
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations();
18196
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations2();
18197 287 return 0;
18198 288 }
18199
18200 16057 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18201 {
18202 byte tempbyte;
18203
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8945 times.
16057 if(s_version >= 52)
18204
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_getcstr(&temp_trigger.label,f))
18205 return qe_invalid;
18206
18207
2/2
✓ Branch 0 taken 7358 times.
✓ Branch 1 taken 8699 times.
16057 if(s_version < 57)
18208 {
18209 7358 int32_t temp_trigflags[6] = {0};
18210 7358 int numtrigs = s_version < 36 ? 3 : 6;
18211
2/2
✓ Branch 0 taken 43290 times.
✓ Branch 1 taken 7358 times.
50648 for ( int32_t q = 0; q < numtrigs; q++ )
18212
1/2
✓ Branch 0 taken 43290 times.
✗ Branch 1 not taken.
43290 if(!p_igetl(&temp_trigflags[q],f))
18213 return qe_invalid;
18214 7358 temp_trigger.trigger_flags.clear();
18215
2/2
✓ Branch 0 taken 1385280 times.
✓ Branch 1 taken 7358 times.
1392638 for(size_t q = 0; q < 32*numtrigs; ++q)
18216 {
18217 1385280 auto ind = q/32;
18218 1385280 auto bit = 1<<(q%32);
18219
2/2
✓ Branch 0 taken 1372321 times.
✓ Branch 1 taken 12959 times.
1385280 if(temp_trigflags[ind] & bit)
18220 12959 temp_trigger.trigger_flags.set(q, true);
18221 1385280 }
18222 7358 }
18223
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 else if(!p_getbitstr(&temp_trigger.trigger_flags,f))
18224 return qe_invalid;
18225
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetl(&temp_trigger.triggerlevel,f))
18226 return qe_invalid;
18227
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.triggerbtn,f))
18228 return qe_invalid;
18229
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.triggeritem,f))
18230 return qe_invalid;
18231
2/2
✓ Branch 0 taken 8945 times.
✓ Branch 1 taken 7112 times.
16057 if(s_version >= 53)
18232 {
18233
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trigtimer,f))
18234 return qe_invalid;
18235 8945 }
18236 else
18237 {
18238
1/2
✓ Branch 0 taken 7112 times.
✗ Branch 1 not taken.
7112 if(!p_getc(&tempbyte, f))
18239 return qe_invalid;
18240 7112 temp_trigger.trigtimer = tempbyte;
18241 }
18242
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.trigsfx,f))
18243 return qe_invalid;
18244
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetl(&temp_trigger.trigchange,f))
18245 return qe_invalid;
18246
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetw(&temp_trigger.trigprox,f))
18247 return qe_invalid;
18248
2/2
✓ Branch 0 taken 8945 times.
✓ Branch 1 taken 7112 times.
16057 if(s_version >= 53)
18249 {
18250
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trigctr,f))
18251 return qe_invalid;
18252 8945 }
18253 else
18254 {
18255
1/2
✓ Branch 0 taken 7112 times.
✗ Branch 1 not taken.
7112 if(!p_getc(&tempbyte,f))
18256 return qe_invalid;
18257 7112 temp_trigger.trigctr = tempbyte;
18258 }
18259
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetl(&temp_trigger.trigctramnt,f))
18260 return qe_invalid;
18261
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.triglbeam,f))
18262 return qe_invalid;
18263
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.trigcschange,f))
18264 return qe_invalid;
18265
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetw(&temp_trigger.spawnitem,f))
18266 return qe_invalid;
18267
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetw(&temp_trigger.spawnenemy,f))
18268 return qe_invalid;
18269
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.exstate,f))
18270 return qe_invalid;
18271
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetl(&temp_trigger.spawnip,f))
18272 return qe_invalid;
18273
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.trigcopycat,f))
18274 return qe_invalid;
18275
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.trigcooldown,f))
18276 return qe_invalid;
18277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16057 times.
16057 if(s_version >= 35)
18278 {
18279
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetw(&temp_trigger.prompt_cid,f))
18280 return qe_invalid;
18281
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_getc(&temp_trigger.prompt_cs,f))
18282 return qe_invalid;
18283
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetw(&temp_trigger.prompt_x,f))
18284 return qe_invalid;
18285
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(!p_igetw(&temp_trigger.prompt_y,f))
18286 return qe_invalid;
18287 16057 }
18288
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 15771 times.
16057 if(s_version >= 36)
18289 {
18290
1/2
✓ Branch 0 taken 15771 times.
✗ Branch 1 not taken.
15771 if(!p_getc(&temp_trigger.trig_lstate,f))
18291 return qe_invalid;
18292
1/2
✓ Branch 0 taken 15771 times.
✗ Branch 1 not taken.
15771 if(!p_getc(&temp_trigger.trig_gstate,f))
18293 return qe_invalid;
18294
1/2
✓ Branch 0 taken 15771 times.
✗ Branch 1 not taken.
15771 if(!p_igetl(&temp_trigger.trig_statetime,f))
18295 return qe_invalid;
18296 15771 }
18297
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 15771 times.
16057 if(s_version >= 37)
18298 {
18299
1/2
✓ Branch 0 taken 15771 times.
✗ Branch 1 not taken.
15771 if(!p_igetw(&temp_trigger.trig_genscr,f))
18300 return qe_invalid;
18301 15771 }
18302
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 15623 times.
16057 if(s_version >= 38)
18303 {
18304
1/2
✓ Branch 0 taken 15623 times.
✗ Branch 1 not taken.
15623 if(!p_getc(&temp_trigger.trig_group,f))
18305 return qe_invalid;
18306
1/2
✓ Branch 0 taken 15623 times.
✗ Branch 1 not taken.
15623 if(!p_igetw(&temp_trigger.trig_group_val,f))
18307 return qe_invalid;
18308 15623 }
18309
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 15587 times.
16057 if(s_version >= 45)
18310 {
18311
1/2
✓ Branch 0 taken 15587 times.
✗ Branch 1 not taken.
15587 if(!p_getc(&temp_trigger.exdoor_dir,f))
18312 return qe_invalid;
18313
1/2
✓ Branch 0 taken 15587 times.
✗ Branch 1 not taken.
15587 if(!p_getc(&temp_trigger.exdoor_ind,f))
18314 return qe_invalid;
18315 15587 }
18316
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8945 times.
16057 if(s_version >= 46)
18317 {
18318
2/2
✓ Branch 0 taken 5355 times.
✓ Branch 1 taken 3590 times.
8945 if (s_version >= 59)
18319 {
18320
1/2
✓ Branch 0 taken 5355 times.
✗ Branch 1 not taken.
5355 if(!p_igetw(&temp_trigger.trig_levelitems,f))
18321 return qe_invalid;
18322 5355 }
18323 else
18324 {
18325
1/2
✓ Branch 0 taken 3590 times.
✗ Branch 1 not taken.
3590 if(!p_getc(&tempbyte,f))
18326 return qe_invalid;
18327 3590 temp_trigger.trig_levelitems = word(tempbyte);
18328 }
18329
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18330 return qe_invalid;
18331
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(s_version >= 48)
18332 {
18333
2/2
✓ Branch 0 taken 26835 times.
✓ Branch 1 taken 8945 times.
35780 for(int q = 0; q < 3; ++q)
18334
1/2
✓ Branch 0 taken 26835 times.
✗ Branch 1 not taken.
26835 if(!p_igetw(&temp_trigger.trigtint[q],f))
18335 return qe_invalid;
18336 8945 }
18337 else
18338 {
18339 for(int q = 0; q < 3; ++q)
18340 if(!p_getc(&temp_trigger.trigtint[q],f))
18341 return qe_invalid;
18342 for(int q = 0; q < 3; ++q)
18343 {
18344 int v = temp_trigger.trigtint[q];
18345 int va = abs(v);
18346 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18347 }
18348 }
18349
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18350 return qe_invalid;
18351
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18352 return qe_invalid;
18353
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trigquaketime,f))
18354 return qe_invalid;
18355
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trigwavytime,f))
18356 return qe_invalid;
18357
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18358 return qe_invalid;
18359
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18360 return qe_invalid;
18361
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18362 return qe_invalid;
18363
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18364 return qe_invalid;
18365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8945 times.
8945 if(!p_getc(&temp_trigger.trig_pushtime,f))
18366 return qe_invalid;
18367 8945 }
18368
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8945 times.
16057 if(s_version >= 47)
18369 {
18370
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18371 return qe_invalid;
18372 8945 }
18373
2/2
✓ Branch 0 taken 8945 times.
✓ Branch 1 taken 7112 times.
16057 if(s_version >= 53)
18374 {
18375
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetl(&temp_trigger.req_level_state, f))
18376 return qe_invalid;
18377
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18378 return qe_invalid;
18379
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18380 return qe_invalid;
18381
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18382 return qe_invalid;
18383
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18384 return qe_invalid;
18385
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18386 return qe_invalid;
18387
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18388 return qe_invalid;
18389
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18390 return qe_invalid;
18391
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetzf(&temp_trigger.player_bounce, f))
18392 return qe_invalid;
18393
1/2
✓ Branch 0 taken 8945 times.
✗ Branch 1 not taken.
8945 if(!p_igetzf(&temp_trigger.req_player_z, f))
18394 return qe_invalid;
18395 8945 }
18396 else
18397 {
18398 7112 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18399 7112 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18400 }
18401
2/2
✓ Branch 0 taken 7358 times.
✓ Branch 1 taken 8699 times.
16057 if(s_version >= 54)
18402 {
18403
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_getc(&temp_trigger.req_player_dir,f))
18404 return qe_invalid;
18405
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18406 return qe_invalid;
18407
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18408 return qe_invalid;
18409
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18410 return qe_invalid;
18411
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18412 return qe_invalid;
18413
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.req_player_x, f))
18414 return qe_invalid;
18415
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.req_player_y, f))
18416 return qe_invalid;
18417 8699 }
18418
2/2
✓ Branch 0 taken 7358 times.
✓ Branch 1 taken 8699 times.
16057 if(s_version >= 56)
18419 {
18420
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_getc(&temp_trigger.dest_player_dir, f))
18421 return qe_invalid;
18422
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18423 return qe_invalid;
18424
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18425 return qe_invalid;
18426
1/2
✓ Branch 0 taken 8699 times.
✗ Branch 1 not taken.
8699 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18427 return qe_invalid;
18428 8699 }
18429
2/2
✓ Branch 0 taken 10702 times.
✓ Branch 1 taken 5355 times.
16057 if(s_version >= 58)
18430 {
18431
1/2
✓ Branch 0 taken 5355 times.
✗ Branch 1 not taken.
5355 if(!p_igetzf(&temp_trigger.trig_gravity, f))
18432 return qe_invalid;
18433
1/2
✓ Branch 0 taken 5355 times.
✗ Branch 1 not taken.
5355 if(!p_igetzf(&temp_trigger.trig_terminal_v, f))
18434 return qe_invalid;
18435 5355 }
18436 16057 return 0;
18437 16057 }
18438
18439 1667401 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18440 {
18441 byte tempbyte;
18442 word combo_has_flags;
18443
2/2
✓ Branch 0 taken 513191 times.
✓ Branch 1 taken 1154210 times.
1667401 if(s_version < 55)
18444 {
18445
1/2
✓ Branch 0 taken 513191 times.
✗ Branch 1 not taken.
513191 if(!p_getc(&tempbyte,f))
18446 return qe_invalid;
18447 513191 combo_has_flags = tempbyte;
18448 513191 }
18449 else
18450 {
18451
1/2
✓ Branch 0 taken 1154210 times.
✗ Branch 1 not taken.
1154210 if(!p_igetw(&combo_has_flags,f))
18452 return qe_invalid;
18453 }
18454
18455 1667401 temp_combo.clear();
18456
2/2
✓ Branch 0 taken 290882 times.
✓ Branch 1 taken 1376519 times.
1667401 if(combo_has_flags)
18457 {
18458
2/2
✓ Branch 0 taken 594664 times.
✓ Branch 1 taken 781855 times.
1376519 if(combo_has_flags&CHAS_BASIC)
18459 {
18460
1/2
✓ Branch 0 taken 781855 times.
✗ Branch 1 not taken.
781855 if(!p_igetl(&temp_combo.tile,f))
18461 return qe_invalid;
18462 781855 temp_combo.o_tile = temp_combo.tile;
18463
18464
1/2
✓ Branch 0 taken 781855 times.
✗ Branch 1 not taken.
781855 if(!p_getc(&temp_combo.flip,f))
18465 return qe_invalid;
18466
18467
1/2
✓ Branch 0 taken 781855 times.
✗ Branch 1 not taken.
781855 if(!p_getc(&temp_combo.walk,f))
18468 return qe_invalid;
18469
18470
1/2
✓ Branch 0 taken 781855 times.
✗ Branch 1 not taken.
781855 if(!p_getc(&temp_combo.type,f))
18471 return qe_invalid;
18472
18473
1/2
✓ Branch 0 taken 781855 times.
✗ Branch 1 not taken.
781855 if(!p_getc(&temp_combo.flag,f))
18474 return qe_invalid;
18475
18476
1/2
✓ Branch 0 taken 781855 times.
✗ Branch 1 not taken.
781855 if(!p_getc(&temp_combo.csets,f))
18477 return qe_invalid;
18478 781855 }
18479
2/2
✓ Branch 0 taken 1373132 times.
✓ Branch 1 taken 3387 times.
1376519 if(combo_has_flags&CHAS_SCRIPT)
18480 {
18481
2/2
✓ Branch 0 taken 3357 times.
✓ Branch 1 taken 30 times.
3387 if (s_version>=41)
18482 {
18483 3357 p_getcstr(&temp_combo.label, f);
18484 3357 }
18485 else
18486 {
18487 char label[12];
18488 30 label[11] = '\0';
18489
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18490
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18491 return qe_invalid;
18492 30 temp_combo.label = label;
18493 }
18494
18495
1/2
✓ Branch 0 taken 3387 times.
✗ Branch 1 not taken.
3387 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18496 3387 auto initd_count = s_version >= 43 ? 8 : 2;
18497
2/2
✓ Branch 0 taken 26916 times.
✓ Branch 1 taken 3387 times.
30303 for ( int32_t q = 0; q < initd_count; q++ )
18498
1/2
✓ Branch 0 taken 26916 times.
✗ Branch 1 not taken.
26916 if(!p_igetl(&temp_combo.initd[q],f))
18499 return qe_invalid;
18500 3387 }
18501
2/2
✓ Branch 0 taken 1192574 times.
✓ Branch 1 taken 183945 times.
1376519 if(combo_has_flags&CHAS_ANIM)
18502 {
18503
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_getc(&temp_combo.frames,f))
18504 return qe_invalid;
18505
18506
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_getc(&temp_combo.speed,f))
18507 return qe_invalid;
18508
18509
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_igetw(&temp_combo.nextcombo,f))
18510 return qe_invalid;
18511
18512
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_getc(&temp_combo.nextcset,f))
18513 return qe_invalid;
18514
18515
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_getc(&temp_combo.skipanim,f))
18516 return qe_invalid;
18517
18518
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_getc(&temp_combo.skipanimy,f))
18519 return qe_invalid;
18520
18521
1/2
✓ Branch 0 taken 183945 times.
✗ Branch 1 not taken.
183945 if(!p_getc(&temp_combo.animflags,f))
18522 return qe_invalid;
18523 183945 }
18524
2/2
✓ Branch 0 taken 1312314 times.
✓ Branch 1 taken 64205 times.
1376519 if(combo_has_flags&CHAS_ATTRIB)
18525 {
18526
2/2
✓ Branch 0 taken 256820 times.
✓ Branch 1 taken 64205 times.
321025 for ( int32_t q = 0; q < 4; q++ )
18527
1/2
✓ Branch 0 taken 256820 times.
✗ Branch 1 not taken.
256820 if(!p_igetl(&temp_combo.attributes[q],f))
18528 return qe_invalid;
18529
2/2
✓ Branch 0 taken 513640 times.
✓ Branch 1 taken 64205 times.
577845 for ( int32_t q = 0; q < 8; q++ )
18530
1/2
✓ Branch 0 taken 513640 times.
✗ Branch 1 not taken.
513640 if(!p_getc(&temp_combo.attribytes[q],f))
18531 return qe_invalid;
18532
2/2
✓ Branch 0 taken 513640 times.
✓ Branch 1 taken 64205 times.
577845 for ( int32_t q = 0; q < 8; q++ )
18533
1/2
✓ Branch 0 taken 513640 times.
✗ Branch 1 not taken.
513640 if(!p_igetw(&temp_combo.attrishorts[q],f))
18534 return qe_invalid;
18535 64205 }
18536
2/2
✓ Branch 0 taken 1360594 times.
✓ Branch 1 taken 15925 times.
1376519 if(combo_has_flags&CHAS_FLAG)
18537 {
18538
1/2
✓ Branch 0 taken 15925 times.
✗ Branch 1 not taken.
15925 if(!p_igetl(&temp_combo.usrflags,f))
18539 return qe_invalid;
18540
1/2
✓ Branch 0 taken 15925 times.
✗ Branch 1 not taken.
15925 if(!p_igetw(&temp_combo.genflags,f))
18541 return qe_invalid;
18542 15925 }
18543
2/2
✓ Branch 0 taken 1360539 times.
✓ Branch 1 taken 15980 times.
1376519 if(combo_has_flags&CHAS_TRIG)
18544 {
18545 15980 byte count = 1;
18546
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8868 times.
15980 if(s_version >= 52)
18547
1/2
✓ Branch 0 taken 8868 times.
✗ Branch 1 not taken.
8868 if(!p_getc(&count, f))
18548 return qe_invalid;
18549
18550
2/2
✓ Branch 0 taken 16057 times.
✓ Branch 1 taken 15980 times.
32037 for(byte q = 0; q < count; ++q)
18551 {
18552 16057 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18553 16057 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18554
1/2
✓ Branch 0 taken 16057 times.
✗ Branch 1 not taken.
16057 if(ret)
18555 return ret;
18556 16057 }
18557
18558
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8868 times.
15980 if(s_version < 52)
18559 {
18560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7112 times.
7112 if(!temp_combo.triggers.empty())
18561 7112 temp_combo.only_gentrig = (temp_combo.triggers[0].trigger_flags.get(TRIGFLAG_ONLYGENTRIG)) ? 1 : 0;
18562 7112 }
18563
1/2
✓ Branch 0 taken 8868 times.
✗ Branch 1 not taken.
8868 else if(!p_getc(&temp_combo.only_gentrig,f))
18564 return qe_invalid;
18565 15980 }
18566
2/2
✓ Branch 0 taken 222186 times.
✓ Branch 1 taken 1154333 times.
1376519 if(combo_has_flags&CHAS_LIFT)
18567 {
18568
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_igetw(&temp_combo.liftcmb,f))
18569 return qe_invalid;
18570
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftcs,f))
18571 return qe_invalid;
18572
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_igetw(&temp_combo.liftundercmb,f))
18573 return qe_invalid;
18574
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftundercs,f))
18575 return qe_invalid;
18576
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftdmg,f))
18577 return qe_invalid;
18578
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftlvl,f))
18579 return qe_invalid;
18580
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftitm,f))
18581 return qe_invalid;
18582
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftflags,f))
18583 return qe_invalid;
18584
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftgfx,f))
18585 return qe_invalid;
18586
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftsprite,f))
18587 return qe_invalid;
18588
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftsfx,f))
18589 return qe_invalid;
18590
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18591 return qe_invalid;
18592
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.liftbreaksfx,f))
18593 return qe_invalid;
18594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154333 times.
1154333 if(s_version >= 34)
18595 {
18596
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.lifthei,f))
18597 return qe_invalid;
18598
1/2
✓ Branch 0 taken 1154333 times.
✗ Branch 1 not taken.
1154333 if(!p_getc(&temp_combo.lifttime,f))
18599 return qe_invalid;
18600 1154333 }
18601
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1154319 times.
1154333 if(s_version >= 39)
18602 {
18603
1/2
✓ Branch 0 taken 1154319 times.
✗ Branch 1 not taken.
1154319 if(!p_getc(&temp_combo.lift_parent_item,f))
18604 return qe_invalid;
18605 1154319 }
18606 1154333 auto& weap_data = temp_combo.lift_weap_data;
18607
4/4
✓ Branch 0 taken 1154234 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 1154210 times.
✓ Branch 3 taken 24 times.
1154333 if(s_version >= 51 && s_version < 55)
18608 {
18609
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18610 return qe_invalid;
18611
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.glow_shape,f))
18612 return qe_invalid;
18613 24 }
18614
18615
2/2
✓ Branch 0 taken 1154210 times.
✓ Branch 1 taken 123 times.
1154333 if(s_version >= 55)
18616 {
18617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154210 times.
1154210 if(auto ret = read_weap_data(weap_data, f))
18618 return ret;
18619 1154210 }
18620 else
18621 {
18622 123 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18623 123 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18624
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 117 times.
123 switch(pitm.type)
18625 {
18626 case itype_bomb:
18627 case itype_sbomb:
18628 6 weap_data = pitm.weap_data;
18629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18630 {
18631 6 weap_data.flags |= wdata_glow_rad;
18632 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18633 6 }
18634 6 break;
18635 default:
18636 117 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18637 117 weap_data.flags |= wdata_glow_rad;
18638 117 }
18639 123 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18640
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 63 times.
123 if(temp_combo.liftflags & LF_BREAKONSOLID)
18641 60 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18642 }
18643 1154333 }
18644
18645
2/2
✓ Branch 0 taken 1340913 times.
✓ Branch 1 taken 35606 times.
1376519 if(combo_has_flags&CHAS_GENERAL)
18646 {
18647
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.speed_mult,f))
18648 return qe_invalid;
18649
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.speed_div,f))
18650 return qe_invalid;
18651
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_igetzf(&temp_combo.speed_add,f))
18652 return qe_invalid;
18653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35606 times.
35606 if(s_version >= 42)
18654 {
18655
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.sfx_appear,f))
18656 return qe_invalid;
18657
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.sfx_disappear,f))
18658 return qe_invalid;
18659
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.sfx_loop,f))
18660 return qe_invalid;
18661
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.sfx_walking,f))
18662 return qe_invalid;
18663
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.sfx_standing,f))
18664 return qe_invalid;
18665
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.spr_appear,f))
18666 return qe_invalid;
18667
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.spr_disappear,f))
18668 return qe_invalid;
18669
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.spr_walking,f))
18670 return qe_invalid;
18671
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.spr_standing,f))
18672 return qe_invalid;
18673 35606 }
18674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35606 times.
35606 if(s_version >= 44)
18675 {
18676
1/2
✓ Branch 0 taken 35606 times.
✗ Branch 1 not taken.
35606 if(!p_getc(&temp_combo.sfx_tap,f))
18677 return qe_invalid;
18678 35606 }
18679
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 35240 times.
35606 if(s_version >= 49)
18680 {
18681
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.sfx_landing,f))
18682 return qe_invalid;
18683 35240 }
18684
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 35240 times.
35606 if(s_version >= 50)
18685 {
18686
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.spr_falling,f))
18687 return qe_invalid;
18688
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.spr_drowning,f))
18689 return qe_invalid;
18690
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18691 return qe_invalid;
18692
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.sfx_falling,f))
18693 return qe_invalid;
18694
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.sfx_drowning,f))
18695 return qe_invalid;
18696
1/2
✓ Branch 0 taken 35240 times.
✗ Branch 1 not taken.
35240 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18697 return qe_invalid;
18698 35240 }
18699
2/2
✓ Branch 0 taken 1860 times.
✓ Branch 1 taken 33746 times.
35606 if(s_version >= 56)
18700 {
18701
1/2
✓ Branch 0 taken 33746 times.
✗ Branch 1 not taken.
33746 if(!p_igetzf(&temp_combo.z_height,f))
18702 return qe_invalid;
18703
1/2
✓ Branch 0 taken 33746 times.
✗ Branch 1 not taken.
33746 if(!p_igetzf(&temp_combo.z_step_height,f))
18704 return qe_invalid;
18705 33746 }
18706
2/2
✓ Branch 0 taken 3283 times.
✓ Branch 1 taken 32323 times.
35606 if(s_version >= 60)
18707 {
18708
1/2
✓ Branch 0 taken 32323 times.
✗ Branch 1 not taken.
32323 if(!p_getc(&temp_combo.dive_under_level,f))
18709 return qe_invalid;
18710 32323 }
18711 35606 }
18712
1/2
✓ Branch 0 taken 1376519 times.
✗ Branch 1 not taken.
1376519 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18713 {
18714 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18715 return ret;
18716 }
18717 1376519 }
18718 1667401 update_combo(temp_combo, s_version);
18719 1667401 return 0;
18720 1667401 }
18721
18722 493 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18723 {
18724
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18725
18726 493 word section_version=0;
18727 493 word combos_used=0;
18728 int32_t dummy;
18729 byte padding;
18730 493 newcombo temp_combo;
18731
18732
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 492 times.
493 if (!should_skip)
18733 {
18734
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 reset_all_combo_animations();
18735
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 init_combo_classes();
18736
18737
2/2
✓ Branch 0 taken 32117760 times.
✓ Branch 1 taken 492 times.
32118252 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18738
1/2
✓ Branch 0 taken 32117760 times.
✗ Branch 1 not taken.
32117760 combobuf[q].clear();
18739 492 }
18740
18741
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 24 times.
493 if(version > 0x192) //Version info
18742 {
18743
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&section_version,f))
18744 {
18745 return qe_invalid;
18746 }
18747 469 FFCore.quest_format[vCombos] = section_version;
18748
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!read_deprecated_section_cversion(f))
18749 {
18750 return qe_invalid;
18751 }
18752
18753 //section size
18754
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetl(&dummy,f))
18755 {
18756 return qe_invalid;
18757 }
18758 469 }
18759
18760
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 288 times.
493 if(section_version > 32) //Cleanup time!
18761 {
18762
2/4
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
205 if(!p_igetw(&combos_used,f))
18763 {
18764 return qe_invalid;
18765 }
18766
2/2
✓ Branch 0 taken 1667401 times.
✓ Branch 1 taken 205 times.
1667606 for(int32_t i=0; i<combos_used; i++)
18767 {
18768
1/2
✓ Branch 0 taken 1667401 times.
✗ Branch 1 not taken.
1667401 auto ret = readcombo_loop(f,section_version,temp_combo);
18769
1/2
✓ Branch 0 taken 1667401 times.
✗ Branch 1 not taken.
1667401 if(ret) return ret;
18770
1/2
✓ Branch 0 taken 1667401 times.
✗ Branch 1 not taken.
1667401 if(i>=start_combo)
18771 {
18772
1/2
✓ Branch 0 taken 1667401 times.
✗ Branch 1 not taken.
1667401 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18773 {
18774 temp_combo.script = 0;
18775 for(int q = 0; q < 8; ++q)
18776 temp_combo.initd[q] = 0;
18777 }
18778
1/2
✓ Branch 0 taken 1667401 times.
✗ Branch 1 not taken.
1667401 combobuf[i] = temp_combo;
18779 1667401 }
18780 1667401 }
18781 205 }
18782 else //Call the old function for all old versions
18783 {
18784
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(ret) return ret; //error, end read
18786 }
18787
18788
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 1 times.
493 if (should_skip)
18789 1 return 0;
18790
18791
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 196 times.
492 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18792 {
18793 196 combobuf[0].walk = 0xF0;
18794 196 combobuf[0].type = 0;
18795 196 combobuf[0].flag = 0;
18796 196 }
18797
18798
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 setup_combo_animations();
18799
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 setup_combo_animations2();
18800 492 return 0;
18801 493 }
18802
18803 410 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18804 {
18805 //these are here to bypass compiler warnings about unused arguments
18806 410 Header=Header;
18807 410 version=version;
18808 410 build=build;
18809
18810 int32_t dummy;
18811 410 word sversion=0, c_sversion;
18812
18813 //section version info
18814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(!p_igetw(&sversion,f))
18815 {
18816 return qe_invalid;
18817 }
18818
18819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (sversion > V_COMBOALIASES)
18820 return qe_version;
18821
18822 410 FFCore.quest_format[vComboAliases] = sversion;
18823
18824
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&c_sversion,f))
18825 {
18826 return qe_invalid;
18827 }
18828
18829 //section size
18830
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&dummy,f))
18831 {
18832 return qe_invalid;
18833 }
18834
18835 410 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18836
18837
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 200 times.
410 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18838 {
18839 200 max_num_combo_aliases = MAX250COMBOALIASES;
18840 200 }
18841
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18842 {
18843 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18844 }
18845
18846
2/2
✓ Branch 0 taken 2129920 times.
✓ Branch 1 taken 410 times.
2130330 for(int32_t j=0; j<max_num_combo_aliases; j++)
18847 {
18848 byte width,height,mask,tempcset;
18849 int32_t count;
18850 word tempword;
18851 byte tempbyte;
18852
18853
1/2
✓ Branch 0 taken 2129920 times.
✗ Branch 1 not taken.
2129920 if(!p_igetw(&tempword,f))
18854 {
18855 return qe_invalid;
18856 }
18857
18858 2129920 combo_aliases[j].combo = tempword;
18859
18860
1/2
✓ Branch 0 taken 2129920 times.
✗ Branch 1 not taken.
2129920 if(!p_getc(&tempbyte,f))
18861 {
18862 return qe_invalid;
18863 }
18864
18865 2129920 combo_aliases[j].cset = tempbyte;
18866
18867
1/2
✓ Branch 0 taken 2129920 times.
✗ Branch 1 not taken.
2129920 if(!p_getc(&width,f))
18868 {
18869 return qe_invalid;
18870 }
18871
18872
1/2
✓ Branch 0 taken 2129920 times.
✗ Branch 1 not taken.
2129920 if(!p_getc(&height,f))
18873 {
18874 return qe_invalid;
18875 }
18876
18877
1/2
✓ Branch 0 taken 2129920 times.
✗ Branch 1 not taken.
2129920 if(!p_getc(&mask,f))
18878 {
18879 return qe_invalid;
18880 }
18881
18882 2129920 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18883
18884 2129920 combo_aliases[j].width = width;
18885 2129920 combo_aliases[j].height = height;
18886 2129920 combo_aliases[j].layermask = mask;
18887 2129920 combo_aliases[j].combos.clear();
18888 2129920 combo_aliases[j].csets.clear();
18889
18890
2/2
✓ Branch 0 taken 2187108 times.
✓ Branch 1 taken 2129920 times.
4317028 for(int32_t k=0; k<count; k++)
18891 {
18892
1/2
✓ Branch 0 taken 2187108 times.
✗ Branch 1 not taken.
2187108 if(!p_igetw(&tempword,f))
18893 {
18894 return qe_invalid;
18895 }
18896
18897 2187108 combo_aliases[j].combos[k] = tempword;
18898 2187108 }
18899
18900
2/2
✓ Branch 0 taken 2187108 times.
✓ Branch 1 taken 2129920 times.
4317028 for(int32_t k=0; k<count; k++)
18901 {
18902
1/2
✓ Branch 0 taken 2187108 times.
✗ Branch 1 not taken.
2187108 if(!p_getc(&tempcset,f))
18903 {
18904 return qe_invalid;
18905 }
18906
18907 2187108 combo_aliases[j].csets[k] = tempcset;
18908 2187108 }
18909 2129920 }
18910
18911 //Combo pools!
18912 410 word num_combo_pools = 0;
18913
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 205 times.
410 if(sversion >= 4)
18914 {
18915
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&num_combo_pools,f))
18916 {
18917 return qe_invalid;
18918 }
18919 205 }
18920
18921
2/2
✓ Branch 0 taken 3358720 times.
✓ Branch 1 taken 410 times.
3359130 for(combo_pool& pool : combo_pools)
18922 {
18923 3358720 pool.clear();
18924 }
18925
18926 410 combo_pool temp_cpool;
18927
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 410 times.
1106 for(word cp = 0; cp < num_combo_pools; ++cp)
18928 {
18929 696 int32_t num_combos_in_pool = 0;
18930
2/4
✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 696 times.
✗ Branch 3 not taken.
696 if(!p_igetl(&num_combos_in_pool,f))
18931 {
18932 return qe_invalid;
18933 }
18934
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 106 times.
696 if(num_combos_in_pool < 1) continue; //nothing to read
18935
18936
1/2
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
590 temp_cpool.clear();
18937
18938 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18939
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2701 times.
3291 for(auto q = 0; q < num_combos_in_pool; ++q)
18940 {
18941
2/4
✓ Branch 0 taken 2701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2701 times.
✗ Branch 3 not taken.
2701 if(!p_igetl(&cp_cid,f))
18942 {
18943 return qe_invalid;
18944 }
18945
2/4
✓ Branch 0 taken 2701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2701 times.
✗ Branch 3 not taken.
2701 if(!p_getc(&cp_cs,f))
18946 {
18947 return qe_invalid;
18948 }
18949
2/4
✓ Branch 0 taken 2701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2701 times.
✗ Branch 3 not taken.
2701 if(!p_igetw(&cp_quant,f))
18950 {
18951 return qe_invalid;
18952 }
18953
1/2
✓ Branch 0 taken 2701 times.
✗ Branch 1 not taken.
2701 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18954 2701 }
18955
18956
1/2
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
590 combo_pools[cp] = temp_cpool;
18957 590 }
18958
18959 //Autocombos!
18960 410 word num_combo_autos = 0;
18961
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 217 times.
410 if (sversion >= 5)
18962 {
18963
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if (!p_igetw(&num_combo_autos, f))
18964 {
18965 return qe_invalid;
18966 }
18967 193 }
18968
18969
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 3358720 times.
3359130 for (combo_auto& cauto : combo_autos)
18970 {
18971
1/2
✓ Branch 0 taken 3358720 times.
✗ Branch 1 not taken.
3358720 cauto.clear(true);
18972 }
18973
18974
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 combo_auto temp_cauto;
18975
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 410 times.
562 for (word ca = 0; ca < num_combo_autos; ++ca)
18976 {
18977 byte type;
18978 int32_t display_cid, erase_cid;
18979 byte flags, arg;
18980
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_getc(&type, f))
18981 {
18982 return qe_invalid;
18983 }
18984
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_igetl(&display_cid, f))
18985 {
18986 return qe_invalid;
18987 }
18988
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_igetl(&erase_cid, f))
18989 {
18990 return qe_invalid;
18991 }
18992
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_getc(&flags, f))
18993 {
18994 return qe_invalid;
18995 }
18996
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_getc(&arg, f))
18997 {
18998 return qe_invalid;
18999 }
19000 152 int32_t num_combos_in_cauto = 0;
19001
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_igetl(&num_combos_in_cauto, f))
19002 {
19003 return qe_invalid;
19004 }
19005
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 21 times.
152 if (num_combos_in_cauto < 1) continue; //nothing to read
19006
19007
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.clear();
19008
19009
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setType(type);
19010
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setDisplay(display_cid);
19011
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setEraseCombo(erase_cid);
19012
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setFlags(flags);
19013
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setArg(arg);
19014
19015 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
19016
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 3377 times.
3508 for (auto q = 0; q < num_combos_in_cauto; ++q)
19017 {
19018
2/4
✓ Branch 0 taken 3377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377 times.
✗ Branch 3 not taken.
3377 if (!p_getc(&ca_ctype, f))
19019 {
19020 return qe_invalid;
19021 }
19022
2/4
✓ Branch 0 taken 3377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377 times.
✗ Branch 3 not taken.
3377 if (!p_igetl(&ca_cid, f))
19023 {
19024 return qe_invalid;
19025 }
19026
1/2
✓ Branch 0 taken 3377 times.
✗ Branch 1 not taken.
3377 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
19027 3377 }
19028
19029
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 combo_autos[ca] = temp_cauto;
19030 131 }
19031
19032 410 return 0;
19033 410 }
19034
19035 824 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
19036 {
19037
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
19038
19039 //these are here to bypass compiler warnings about unused arguments
19040 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
19041 //Capitalized cause it'll save you a headache. -Deedee
19042 824 start_cset=start_cset;
19043 824 max_csets=max_csets;
19044 824 word s_version=0;
19045
19046 miscQdata temp_misc;
19047 824 memcpy(&temp_misc, Misc, sizeof(temp_misc));
19048
19049 byte temp_colordata[48];
19050 char temp_palname[PALNAMESIZE+1];
19051
19052 int32_t dummy;
19053 word palcycles;
19054
19055
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(version > 0x192)
19056 {
19057 //section version info
19058
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&s_version,f))
19059 {
19060 return qe_invalid;
19061 }
19062
19063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if (s_version > V_CSETS)
19064 return qe_version;
19065
19066 800 FFCore.quest_format[vCSets] = s_version;
19067
19068
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&dummy,f))
19069 {
19070 return qe_invalid;
19071 }
19072
19073 //section size
19074
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetl(&dummy,f))
19075 {
19076 return qe_invalid;
19077 }
19078 800 }
19079
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 210 times.
824 if (s_version < 5)
19080 {
19081
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 596 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 6 times.
614 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
19082
19083 //finally... section data
19084 614 int32_t q = 0;
19085 614 int32_t p = -15;
19086
2/2
✓ Branch 0 taken 147360 times.
✓ Branch 1 taken 614 times.
147974 for(int32_t i=0; i<oldpdTOTAL; ++i)
19087 {
19088 147360 memset(temp_colordata, 0, 48);
19089
19090
1/2
✓ Branch 0 taken 147360 times.
✗ Branch 1 not taken.
147360 if(!pfread(temp_colordata,48,f))
19091 {
19092 return qe_invalid;
19093 }
19094
19095
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 147120 times.
147360 if (should_skip)
19096 240 continue;
19097
19098 147120 memcpy(&colordata[q*48], temp_colordata, 48);
19099
19100 147120 ++q;
19101
8/8
✓ Branch 0 taken 137312 times.
✓ Branch 1 taken 9808 times.
✓ Branch 2 taken 10421 times.
✓ Branch 3 taken 126891 times.
✓ Branch 4 taken 1226 times.
✓ Branch 5 taken 9195 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1190 times.
147120 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
19102 {
19103
1/2
✓ Branch 0 taken 10385 times.
✗ Branch 1 not taken.
10385 if (s_version < 5) //Bumping up the size of level palettes
19104 {
19105 10385 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19106 10385 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19107 10385 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19108 10385 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19109 10385 q+=4;
19110 10385 }
19111 else
19112 {
19113 for(int m = 0; m < 4; ++m)
19114 {
19115 memset(temp_colordata, 0, 48);
19116 if(!pfread(temp_colordata,48,f))
19117 {
19118 return qe_invalid;
19119 }
19120 memcpy(&colordata[q*48], temp_colordata, 48);
19121 ++q;
19122 }
19123 }
19124 10385 }
19125 147120 ++p;
19126 147120 }
19127
19128
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 596 times.
614 if(RealOldVerion)
19129 {
19130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19131 {
19132 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19133 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19134 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19135 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19136 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19137 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19138 18 }
19139 18 }
19140 else
19141 {
19142 596 memset(temp_colordata, 0, 48);
19143
19144
2/2
✓ Branch 0 taken 1867268 times.
✓ Branch 1 taken 596 times.
1867864 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19145 {
19146
1/2
✓ Branch 0 taken 1867268 times.
✗ Branch 1 not taken.
1867268 if(!pfread(temp_colordata,48,f))
19147 {
19148 return qe_invalid;
19149 }
19150
19151
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1864135 times.
1867268 if (should_skip)
19152 3133 continue;
19153
19154 1864135 memcpy(&colordata[q*48], temp_colordata, 48);
19155
19156 1864135 ++q;
19157
7/8
✓ Branch 0 taken 1864135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143395 times.
✓ Branch 3 taken 1720740 times.
✓ Branch 4 taken 1190 times.
✓ Branch 5 taken 142205 times.
✓ Branch 6 taken 1062 times.
✓ Branch 7 taken 128 times.
1864135 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19158 {
19159
1/2
✓ Branch 0 taken 143267 times.
✗ Branch 1 not taken.
143267 if (s_version < 5) //Bumping up the size of level palettes
19160 {
19161 143267 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19162 143267 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19163 143267 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19164 143267 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19165 143267 q+=4;
19166 143267 }
19167 else
19168 {
19169 for(int m = 0; m < 4; ++m)
19170 {
19171 memset(temp_colordata, 0, 48);
19172 if(!pfread(temp_colordata,48,f))
19173 {
19174 return qe_invalid;
19175 }
19176 memcpy(&colordata[q*48], temp_colordata, 48);
19177 ++q;
19178 }
19179 }
19180 143267 }
19181 1864135 ++p;
19182 1864135 }
19183
19184
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 531 times.
596 if(s_version < 4)
19185 {
19186
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19187 {
19188 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19189 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19190 64 }
19191 65 }
19192 else
19193 {
19194
2/2
✓ Branch 0 taken 1767168 times.
✓ Branch 1 taken 531 times.
1767699 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19195 {
19196
1/2
✓ Branch 0 taken 1767168 times.
✗ Branch 1 not taken.
1767168 if(!pfread(temp_colordata,48,f))
19197 {
19198 return qe_invalid;
19199 }
19200
19201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1767168 times.
1767168 if (should_skip)
19202 continue;
19203
19204 1767168 memcpy(&colordata[q*48], temp_colordata, 48);
19205 1767168 ++q;
19206
5/6
✓ Branch 0 taken 1767168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135936 times.
✓ Branch 3 taken 1631232 times.
✓ Branch 4 taken 1062 times.
✓ Branch 5 taken 134874 times.
1767168 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19207 {
19208
1/2
✓ Branch 0 taken 134874 times.
✗ Branch 1 not taken.
134874 if (s_version < 5) //Bumping up the size of level palettes
19209 {
19210 134874 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19211 134874 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19212 134874 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19213 134874 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19214 134874 q+=4;
19215 134874 }
19216 else
19217 {
19218 for(int m = 0; m < 4; ++m)
19219 {
19220 memset(temp_colordata, 0, 48);
19221 if(!pfread(temp_colordata,48,f))
19222 {
19223 return qe_invalid;
19224 }
19225 memcpy(&colordata[q*48], temp_colordata, 48);
19226 ++q;
19227 }
19228 }
19229 134874 }
19230 1767168 ++p;
19231 1767168 }
19232
19233 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19234 }
19235 }
19236 614 }
19237 else
19238 {
19239
2/2
✓ Branch 0 taken 1837290 times.
✓ Branch 1 taken 210 times.
1837500 for(int32_t i=0; i<pdTOTAL255; ++i)
19240 {
19241 1837290 memset(temp_colordata, 0, 48);
19242
19243
1/2
✓ Branch 0 taken 1837290 times.
✗ Branch 1 not taken.
1837290 if(!pfread(temp_colordata,48,f))
19244 {
19245 return qe_invalid;
19246 }
19247
19248 1837290 memcpy(&colordata[i*48], temp_colordata, 48);
19249 1837290 }
19250 }
19251
19252
4/4
✓ Branch 0 taken 823 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 165 times.
✓ Branch 3 taken 658 times.
824 if (!should_skip && s_version < 6)
19253 {
19254
2/2
✓ Branch 0 taken 276328416 times.
✓ Branch 1 taken 658 times.
276329074 for (int i = 0; i < psTOTAL255; i++)
19255 {
19256 276328416 colordata[i] = _rgb_scale_6[colordata[i]];
19257 276328416 }
19258 658 }
19259
19260
5/6
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 800 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
824 if((version < 0x192)||((version == 0x192)&&(build<76)))
19261 {
19262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19263 18 init_palnames();
19264 18 }
19265 else
19266 {
19267 806 int32_t palnamestoread = 0;
19268
19269
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 741 times.
806 if(s_version < 3)
19270 65 palnamestoread = OLDMAXLEVELS;
19271 else
19272 741 palnamestoread = 512;
19273
19274
2/2
✓ Branch 0 taken 396032 times.
✓ Branch 1 taken 806 times.
396838 for(int32_t i=0; i<palnamestoread; ++i)
19275 {
19276
1/2
✓ Branch 0 taken 396032 times.
✗ Branch 1 not taken.
396032 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19277 {
19278 return qe_invalid;
19279 }
19280
19281
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 395776 times.
396032 if (!should_skip)
19282 395776 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19283 396032 }
19284
19285
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 805 times.
806 if (should_skip)
19286 1 return 0;
19287
19288
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 805 times.
17189 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19289 {
19290 16384 memset(palnames[i], 0, PALNAMESIZE);
19291 16384 }
19292 }
19293
19294
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 800 times.
823 if(version > 0x192)
19295 {
19296
2/2
✓ Branch 0 taken 204800 times.
✓ Branch 1 taken 800 times.
205600 for(int32_t i=0; i<256; i++)
19297 {
19298
2/2
✓ Branch 0 taken 614400 times.
✓ Branch 1 taken 204800 times.
819200 for(int32_t j=0; j<3; j++)
19299 {
19300 614400 temp_misc.cycles[i][j].first=0;
19301 614400 temp_misc.cycles[i][j].count=0;
19302 614400 temp_misc.cycles[i][j].speed=0;
19303 614400 }
19304 204800 }
19305
19306
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&palcycles,f))
19307 {
19308 return qe_invalid;
19309 }
19310
19311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if (palcycles > NUM_PAL_CYCLES)
19312 {
19313 return qe_invalid;
19314 }
19315
19316
2/2
✓ Branch 0 taken 22327 times.
✓ Branch 1 taken 800 times.
23127 for(int32_t i=0; i<palcycles; i++)
19317 {
19318
2/2
✓ Branch 0 taken 66981 times.
✓ Branch 1 taken 22327 times.
89308 for(int32_t j=0; j<3; j++)
19319 {
19320
1/2
✓ Branch 0 taken 66981 times.
✗ Branch 1 not taken.
66981 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19321 {
19322 return qe_invalid;
19323 }
19324 66981 }
19325
19326
2/2
✓ Branch 0 taken 66981 times.
✓ Branch 1 taken 22327 times.
89308 for(int32_t j=0; j<3; j++)
19327 {
19328
1/2
✓ Branch 0 taken 66981 times.
✗ Branch 1 not taken.
66981 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19329 {
19330 return qe_invalid;
19331 }
19332 66981 }
19333
19334
2/2
✓ Branch 0 taken 66981 times.
✓ Branch 1 taken 22327 times.
89308 for(int32_t j=0; j<3; j++)
19335 {
19336
1/2
✓ Branch 0 taken 66981 times.
✗ Branch 1 not taken.
66981 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19337 {
19338 return qe_invalid;
19339 }
19340 66981 }
19341 22327 }
19342
19343 800 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19344 800 }
19345
19346 823 return 0;
19347 824 }
19348
19349 824 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19350 {
19351
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 24 times.
824 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19352
19353 824 int32_t tiles_used=0;
19354 824 word section_version = 0;
19355 824 int32_t section_size= 0;
19356 824 byte *temp_tile = new byte[tilesize(tf32Bit)];
19357
19358 //Tile Expansion
19359 //if ( version >= 0x254 && build >= 41 )
19360
4/4
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 608 times.
824 if (version < 0x254 && build < 41)
19361 {
19362 608 max_tiles = ZC250MAXTILES;
19363 608 }
19364
19365
19366
2/6
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
824 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19367 {
19368 if(!init_tiles_for_190(true, Header))
19369 {
19370 al_trace("Unable to initialize tiles\n");
19371 }
19372
19373 delete[] temp_tile;
19374 temp_tile=NULL;
19375 return 0;
19376 }
19377 else
19378 {
19379
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 800 times.
824 if(version > 0x192)
19380 {
19381 //section version info
19382
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&section_version,f))
19383 {
19384 delete[] temp_tile;
19385 return qe_invalid;
19386 }
19387
19388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if (section_version > V_TILES)
19389 return qe_version;
19390
19391 800 FFCore.quest_format[vTiles] = section_version;
19392
19393
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!read_deprecated_section_cversion(f))
19394 {
19395 delete[] temp_tile;
19396 return qe_invalid;
19397 }
19398
19399 //section size
19400
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetl(&section_size,f))
19401 {
19402 delete[] temp_tile;
19403 return qe_invalid;
19404 }
19405 800 }
19406
19407 //if ( build < 41 )
19408 //{
19409 // tiles_used = ZC250MAXTILES;
19410 //}
19411
19412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(version < 0x174)
19413 {
19414 tiles_used=TILES_PER_PAGE*4;
19415 } //no expanded tile space
19416
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 806 times.
824 else if(version < 0x191)
19417 {
19418 18 tiles_used=OLDMAXTILES;
19419 18 }
19420 else
19421 {
19422 //finally... section data
19423
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 210 times.
806 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19424 {
19425
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&tiles_used,f))
19426 {
19427 delete[] temp_tile;
19428 return qe_invalid;
19429 }
19430 210 }
19431 else
19432 {
19433
1/2
✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
596 if(!p_igetw(&tiles_used,f))
19434 {
19435 delete[] temp_tile;
19436 return qe_invalid;
19437 }
19438 }
19439 }
19440
19441
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 tiles_used=zc_min(tiles_used, max_tiles);
19442
19443 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19444 //if ( version < 0x254 && build < 41 )
19445
3/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 614 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 210 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
824 if ( version < 0x254 || (version == 0x254 && build < 41) )
19446 //if ( build < 41 )
19447 {
19448
1/2
✓ Branch 0 taken 614 times.
✗ Branch 1 not taken.
614 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19449 614 }
19450 else //2.55
19451 {
19452
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19453 }
19454
19455 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19456
19457
19458
2/2
✓ Branch 0 taken 19108668 times.
✓ Branch 1 taken 824 times.
19109492 for(int32_t i=0; i<tiles_used; ++i)
19459 {
19460 19108668 byte format=tf4Bit;
19461 19108668 memset(temp_tile, 0, tilesize(tf32Bit));
19462
19463
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 16123212 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19108668 if((version>0x211)||((version==0x211)&&(build>4)))
19464 {
19465
1/2
✓ Branch 0 taken 16123212 times.
✗ Branch 1 not taken.
16123212 if(!p_getc(&format,f))
19466 {
19467 delete[] temp_tile;
19468 return qe_invalid;
19469 }
19470 16123212 }
19471
4/4
✓ Branch 0 taken 8166070 times.
✓ Branch 1 taken 10942598 times.
✓ Branch 2 taken 3785496 times.
✓ Branch 3 taken 4380574 times.
19108668 if(section_version > 2 && !format)
19472 {
19473 4380574 reset_tile(buf,start_tile+i,tf4Bit);
19474 4380574 continue;
19475 }
19476
19477
2/2
✓ Branch 0 taken 14220486 times.
✓ Branch 1 taken 507608 times.
14728094 int size = format == tf4Bit ? 128 : tilesize(format);
19478
1/2
✓ Branch 0 taken 14728094 times.
✗ Branch 1 not taken.
14728094 if(!pfread(temp_tile,size,f))
19479 {
19480 delete[] temp_tile;
19481 return qe_invalid;
19482 }
19483
19484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14728094 times.
14728094 if (should_skip)
19485 continue;
19486
19487 14728094 buf[start_tile+i].format=format;
19488
19489
2/2
✓ Branch 0 taken 14514420 times.
✓ Branch 1 taken 213674 times.
14728094 if(buf[start_tile+i].data)
19490 {
19491 14514420 free(buf[start_tile+i].data);
19492 14514420 buf[start_tile+i].data=NULL;
19493 14514420 }
19494
19495 14728094 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19496
19497
2/2
✓ Branch 0 taken 14220486 times.
✓ Branch 1 taken 507608 times.
14728094 if (format == tf4Bit)
19498 {
19499 byte temp[256];
19500 14220486 byte *si = temp_tile + 128;
19501 14220486 byte *di = temp + 256;
19502
19503
2/2
✓ Branch 0 taken 1820222208 times.
✓ Branch 1 taken 14220486 times.
1834442694 for(int i=127; i>=0; --i)
19504 {
19505 1820222208 (*(--di)) = (*(--si)) >> 4;
19506 1820222208 (*(--di)) = (*si) & 15;
19507 1820222208 }
19508
19509 14220486 memcpy(buf[start_tile+i].data,temp,256);
19510 14220486 }
19511 else
19512 {
19513 507608 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19514 }
19515 14728094 }
19516 }
19517
19518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if (should_skip)
19519 return 0;
19520
19521
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 614 times.
824 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19522 {
19523
2/2
✓ Branch 0 taken 91473720 times.
✓ Branch 1 taken 614 times.
91474334 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19524 {
19525
19526 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19527 91473720 reset_tile(buf,q,tf4Bit);
19528
19529
19530 /*
19531
19532 byte tempbyte;
19533 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19534 {
19535 tempbyte=buf[ZC250MAXTILES-1].data[i];
19536 buf[q].data[i] = tempbyte;
19537 }
19538 //int32_t temp = tempbyte=buf[130].data[i];
19539 //buf[q].data = buf[ZC250MAXTILES-1].data;
19540 */
19541 //reset_tile(buf,q,tf4Bit);
19542 91473720 }
19543
19544 614 }
19545
19546
4/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 614 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 210 times.
824 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19547 {
19548
2/2
✓ Branch 0 taken 30754278 times.
✓ Branch 1 taken 614 times.
30754892 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19549 {
19550 30754278 reset_tile(buf,i,tf4Bit);
19551 30754278 }
19552 614 }
19553 else
19554 {
19555
2/2
✓ Branch 0 taken 36305214 times.
✓ Branch 1 taken 210 times.
36305424 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19556 {
19557 36305214 reset_tile(buf,i,tf4Bit);
19558 36305214 }
19559 }
19560
19561
5/6
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 800 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
824 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19562 {
19563
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19564 {
19565 byte tempbyte;
19566 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19567
19568
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19569 {
19570 1536 tempbyte=buf[23].data[i];
19571 1536 buf[23].data[i]=buf[24].data[i];
19572 1536 buf[24].data[i]=buf[25].data[i];
19573 1536 buf[25].data[i]=buf[26].data[i];
19574 1536 buf[26].data[i]=tempbyte;
19575 1536 }
19576 //swim tiles are out of order, too, but nobody cared? -Z
19577
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19578 {
19579 1536 tempbyte=buf[floattile+11].data[i];
19580 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19581 1536 buf[floattile+12].data[i]=tempbyte;
19582 1536 }
19583 6 }
19584 24 }
19585
19586
3/6
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 741 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
824 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19587 {
19588
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19589 {
19590 byte tempbyte;
19591
19592
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19593 {
19594 5632 tempbyte=buf[130].data[i];
19595 5632 buf[130].data[i]=buf[132].data[i];
19596 5632 buf[132].data[i]=tempbyte;
19597
19598 5632 tempbyte=buf[131].data[i];
19599 5632 buf[131].data[i]=buf[133].data[i];
19600 5632 buf[133].data[i]=tempbyte;
19601 5632 }
19602 22 }
19603 83 }
19604
19605 824 al_trace("Registering blank tiles\n");
19606 824 register_blank_tiles();
19607
19608 //memset(temp_tile, 0, tilesize(tf32Bit));
19609
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 delete[] temp_tile;
19610 824 temp_tile=NULL;
19611 824 return 0;
19612 824 }
19613
19614 492 int32_t readmidis(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19615 {
19616
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 469 times.
492 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19617
19618 static byte fake_midi_flags[32];
19619
19620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19621 int32_t dummy;
19622 word dummy2;
19623 // zcmidi_ temp_midi;
19624 int32_t tunes_to_read;
19625 492 int32_t tune_count=0;
19626 492 word section_version=0;
19627 492 zctune temp;
19628
19629
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 469 times.
492 if(Header->zelda_version < 0x193)
19630 {
19631 // mf=Header->data_flags+ZQ_MIDIS2;
19632
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19633 {
19634 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19635 22 }
19636 else
19637 {
19638 1 tunes_to_read=MAXCUSTOMTUNES;
19639 }
19640 23 }
19641 else
19642 {
19643 //section version info
19644
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&section_version,f))
19645 {
19646 return qe_invalid;
19647 }
19648
19649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (section_version > V_MIDIS)
19650 return qe_version;
19651
19652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (!should_skip)
19653 469 FFCore.quest_format[vMIDIs] = section_version;
19654
19655
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&dummy2,f))
19656 {
19657 return qe_invalid;
19658 }
19659
19660 //section size
19661
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy,f))
19662 {
19663 return qe_invalid;
19664 }
19665
19666 //finally... section data
19667
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!pfread(midi_flags,sizeof(midi_flags),f))
19668 {
19669 return qe_invalid;
19670 }
19671
19672 469 tunes_to_read=MAXCUSTOMTUNES;
19673 }
19674
19675
2/2
✓ Branch 0 taken 123984 times.
✓ Branch 1 taken 492 times.
124476 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19676 {
19677
2/2
✓ Branch 0 taken 10302 times.
✓ Branch 1 taken 113682 times.
123984 if(get_bit(mf, i))
19678 {
19679 10302 ++tune_count;
19680 10302 }
19681 123984 }
19682
19683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if (!should_skip)
19684 492 reset_tunes(tunes); //reset_midis(midis);
19685
19686
2/2
✓ Branch 0 taken 119144 times.
✓ Branch 1 taken 492 times.
119636 for(int32_t i=0; i<tunes_to_read; i++)
19687 {
19688 119144 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19689
19690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119144 times.
119144 if (!should_skip)
19691 119144 tunes[i].reset(); // reset_midi(midis+i);
19692
19693
2/2
✓ Branch 0 taken 108842 times.
✓ Branch 1 taken 10302 times.
119144 if(get_bit(mf,i))
19694 {
19695
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7639 times.
10302 if(section_version < 4)
19696 {
19697
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19698 {
19699 return qe_invalid;
19700 }
19701 2663 }
19702 else
19703 {
19704
1/2
✓ Branch 0 taken 7639 times.
✗ Branch 1 not taken.
7639 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19705 {
19706 return qe_invalid;
19707 }
19708 }
19709
19710
1/2
✓ Branch 0 taken 10302 times.
✗ Branch 1 not taken.
10302 if(!p_igetl(&temp.start,f))
19711 {
19712 return qe_invalid;
19713 }
19714
19715
1/2
✓ Branch 0 taken 10302 times.
✗ Branch 1 not taken.
10302 if(!p_igetl(&temp.loop_start,f))
19716 {
19717 return qe_invalid;
19718 }
19719
19720
1/2
✓ Branch 0 taken 10302 times.
✗ Branch 1 not taken.
10302 if(!p_igetl(&temp.loop_end,f))
19721 {
19722 return qe_invalid;
19723 }
19724
19725
1/2
✓ Branch 0 taken 10302 times.
✗ Branch 1 not taken.
10302 if(!p_igetw(&temp.loop,f))
19726 {
19727 return qe_invalid;
19728 }
19729
19730
1/2
✓ Branch 0 taken 10302 times.
✗ Branch 1 not taken.
10302 if(!p_igetw(&temp.volume,f))
19731 {
19732 return qe_invalid;
19733 }
19734
19735
2/2
✓ Branch 0 taken 10053 times.
✓ Branch 1 taken 249 times.
10302 if(Header->zelda_version < 0x193)
19736 {
19737
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19738 {
19739 return qe_invalid;
19740 }
19741 249 }
19742
19743
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7639 times.
10302 if(section_version >= 3)
19744 {
19745
1/2
✓ Branch 0 taken 7639 times.
✗ Branch 1 not taken.
7639 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19746 {
19747 return qe_invalid;
19748 }
19749 7639 }
19750
19751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10302 times.
10302 if (!should_skip)
19752 10302 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19753
19754
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7639 times.
10302 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19755 {
19756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19757 {
19758 if (read_midi(f)==NULL)
19759 {
19760 return qe_invalid;
19761 }
19762
19763 continue;
19764 }
19765
19766 // old format - a midi is a midi
19767
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19768 {
19769 return qe_invalid;
19770 }
19771 2663 }
19772 else
19773 {
19774 byte format;
19775
1/2
✓ Branch 0 taken 7639 times.
✗ Branch 1 not taken.
7639 if(!pfread(&format,sizeof(format),f))
19776 {
19777 return qe_invalid;
19778 }
19779
19780 // MIDI is the only format saved here.
19781 // Never did more than MIDI for a zctune, and no plans to now.
19782
1/2
✓ Branch 0 taken 7639 times.
✗ Branch 1 not taken.
7639 if (format != MFORMAT_MIDI)
19783 {
19784 return qe_invalid;
19785 }
19786
19787 7639 tunes[i].data = read_midi(f);
19788
1/2
✓ Branch 0 taken 7639 times.
✗ Branch 1 not taken.
7639 if (!tunes[i].data)
19789 {
19790 return qe_invalid;
19791 }
19792 }
19793 10302 }
19794 119144 }
19795
19796 492 return 0;
19797 492 }
19798
19799 492 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19800 {
19801
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
492 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19802
19803 int32_t dummy;
19804 ZCHEATS tempzcheats;
19805 492 char temp_use_cheats=1;
19806 492 memset(&tempzcheats, 0, sizeof(tempzcheats));
19807 492 word s_version = 0;
19808
19809
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 469 times.
492 if(Header->zelda_version > 0x192)
19810 {
19811 //section version info
19812
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&s_version,f))
19813 {
19814 return qe_invalid;
19815 }
19816
19817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (s_version > V_CHEATS)
19818 return qe_version;
19819
19820 469 FFCore.quest_format[vCheats] = s_version;
19821
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetw(&dummy,f))
19822 {
19823 return qe_invalid;
19824 }
19825
19826 //section size
19827
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy,f))
19828 {
19829 return qe_invalid;
19830 }
19831
19832 //finally... section data
19833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(!p_getc(&temp_use_cheats,f))
19834 {
19835 return qe_invalid;
19836 }
19837 469 }
19838
19839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(Header->data_flags[ZQ_CHEATS2])
19840 {
19841
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(!p_igetl(&tempzcheats.flags,f))
19842 {
19843 return qe_invalid;
19844 }
19845
19846
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19847 {
19848 return qe_invalid;
19849 }
19850 492 }
19851
19852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if (should_skip)
19853 return 0;
19854
19855 492 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19856 492 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19857
19858 492 return 0;
19859 492 }
19860
19861 299 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19862 {
19863
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
299 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19864
19865 byte padding, tempbyte;
19866
19867 // Legacy item properties (now integrated into itemdata)
19868 byte sword_hearts[4];
19869 byte beam_hearts[4];
19870 299 byte beam_percent=0;
19871 word beam_power[4];
19872 299 byte hookshot_length=99;
19873 299 byte hookshot_links=100;
19874 299 byte longshot_length=99;
19875 299 byte longshot_links=100;
19876 299 byte moving_fairy_hearts=3;
19877 299 byte moving_fairy_heart_percent=0;
19878 299 byte stationary_fairy_hearts=3;
19879 299 byte stationary_fairy_heart_percent=0;
19880 299 byte moving_fairy_magic=0;
19881 299 byte moving_fairy_magic_percent=0;
19882 299 byte stationary_fairy_magic=0;
19883 299 byte stationary_fairy_magic_percent=0;
19884 299 byte blue_potion_hearts=100;
19885 299 byte blue_potion_heart_percent=1;
19886 299 byte red_potion_hearts=100;
19887 299 byte red_potion_heart_percent=1;
19888 299 byte blue_potion_magic=100;
19889 299 byte blue_potion_magic_percent=1;
19890 299 byte red_potion_magic=100;
19891 299 byte red_potion_magic_percent=1;
19892
19893 299 byte bomb_ratio = 4;
19894
19895 299 subscr_mode = 0;
19896
19897 /* HIGHLY UNORTHODOX UPDATING THING, by L
19898 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19899 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19900 * changing from 13 to 14.
19901 */
19902
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 14)
19903 82 fixpolsvoice=true;
19904
19905 /* End highly unorthodox updating thing */
19906
19907
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 111 times.
299 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19908 111 temp_zinit.jump_hero_layer_threshold=0;
19909
19910
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
299 if(s_version >= 10)
19911 {
19912 char temp;
19913
19914 //new-style items
19915
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 217 times.
55769 for(int32_t j=0; j<256; j++)
19916 {
19917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(!p_getc(&temp,f))
19918 return qe_invalid;
19919
19920 55552 temp_zinit.set_item(j, temp != 0);
19921 55552 }
19922 217 }
19923
19924
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19925 {
19926 char temp;
19927
19928 //finally... section data
19929
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
19930 //new only
19931
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19932 {
19933 //OLD-style items... sigh
19934
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 60 times.
277 if(s_version < 10)
19935 {
19936
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19937 {
19938 return qe_invalid;
19939 }
19940
19941 60 temp_zinit.set_item(iRaft, temp != 0);
19942
19943
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19944 {
19945 return qe_invalid;
19946 }
19947
19948 60 temp_zinit.set_item(iLadder, temp != 0);
19949
19950
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19951 {
19952 return qe_invalid;
19953 }
19954
19955 60 temp_zinit.set_item(iBook, temp != 0);
19956
19957
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19958 {
19959 return qe_invalid;
19960 }
19961
19962 60 temp_zinit.set_item(iMKey, temp != 0);
19963
19964
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19965 {
19966 return qe_invalid;
19967 }
19968
19969 60 temp_zinit.set_item(iFlippers, temp != 0);
19970
19971
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19972 {
19973 return qe_invalid;
19974 }
19975
19976 60 temp_zinit.set_item(iBoots, temp != 0);
19977 60 }
19978 277 }
19979
19980
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
19981 {
19982 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19983
19984
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19985 {
19986 return qe_invalid;
19987 }
19988
19989
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19990 {
19991 return qe_invalid;
19992 }
19993
19994
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19995 {
19996 return qe_invalid;
19997 }
19998
19999
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
20000 {
20001 return qe_invalid;
20002 }
20003
20004
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
20005 {
20006 return qe_invalid;
20007 }
20008
20009
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
20010 {
20011 return qe_invalid;
20012 }
20013
20014
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
20015 {
20016 return qe_invalid;
20017 }
20018
20019 //old only
20020
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20021 {
20022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
20023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
20024
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
20025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
20026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
20027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
20028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
20029 4 }
20030
20031 //rings start at level 2... wtf
20032 //account for this -DD
20033 64 tempring <<= 1;
20034 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
20035 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
20036 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
20037 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
20038 //bracelet ALSO starts at level 2 :-( -DD
20039 64 tempbracelet<<=1;
20040 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
20041 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
20042 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
20043
20044 //new only
20045
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
20046 {
20047
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20048 {
20049
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20050 {
20051 return qe_invalid;
20052 }
20053 32 }
20054 1 }
20055
20056 char tempcandle, tempboomerang, temparrow, tempwhistle;
20057
20058
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
20059 {
20060 return qe_invalid;
20061 }
20062
20063
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
20064 {
20065 return qe_invalid;
20066 }
20067
20068
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
20069 {
20070 return qe_invalid;
20071 }
20072
20073
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
20074 {
20075 return qe_invalid;
20076 }
20077
20078 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
20079
20080
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
20081 {
20082 return qe_invalid;
20083 }
20084
20085 //old only
20086
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20087 {
20088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
20089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
20090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
20091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
20092 4 }
20093
20094 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
20095 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
20096 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
20097 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
20098 //What about the potion...?
20099
20100 64 }
20101
20102
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20103 {
20104 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
20105 //to jab out my eye...
20106
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20107 return qe_invalid;
20108 264 temp_zinit.counter[crBOMBS] = padding;
20109
20110
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20111 return qe_invalid;
20112 264 temp_zinit.counter[crSBOMBS] = padding;
20113 264 }
20114
20115 //Back to more OLD item code
20116
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20117 {
20118
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
20119 //new only
20120
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20121 {
20122
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20123 {
20124 return qe_invalid;
20125 }
20126
20127 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20128
20129
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20130 {
20131 return qe_invalid;
20132 }
20133
20134 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20135
20136
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20137 {
20138 return qe_invalid;
20139 }
20140
20141 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20142
20143
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20144 {
20145 return qe_invalid;
20146 }
20147
20148 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20149
20150
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20151 {
20152 return qe_invalid;
20153 }
20154
20155 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20156
20157
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20158 {
20159 return qe_invalid;
20160 }
20161
20162 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20163
20164
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20165 {
20166 return qe_invalid;
20167 }
20168
20169 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20170
20171
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20172 {
20173 return qe_invalid;
20174 }
20175
20176 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20177
20178
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20179 {
20180 return qe_invalid;
20181 }
20182
20183 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20184
20185
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20186 {
20187 return qe_invalid;
20188 }
20189
20190
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20191 {
20192
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20193 {
20194
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20195 {
20196 return qe_invalid;
20197 }
20198 32 }
20199 1 }
20200 60 }
20201 64 }
20202
20203 //old only
20204
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20205 {
20206 byte equipment, tmpitm; //bit flags
20207
20208
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20209 {
20210 return qe_invalid;
20211 }
20212
20213 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20214 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20215 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20216 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20217 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20218 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20219
20220
20221
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20222 {
20223 return qe_invalid;
20224 }
20225
20226 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20227 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20228 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20229 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20230 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20231 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20232 4 }
20233
20234
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20235 return qe_invalid;
20236 281 temp_zinit.mcounter[crLIFE] = tempbyte;
20237
20238
20239
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20240 {
20241 byte temphp;
20242
20243
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20244 {
20245 return qe_invalid;
20246 }
20247
20248 64 temp_zinit.counter[crLIFE]=temphp;
20249
20250
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20251 {
20252 return qe_invalid;
20253 }
20254
20255 64 temp_zinit.cont_heart=temphp;
20256 64 }
20257 else
20258 {
20259
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20260 {
20261 return qe_invalid;
20262 }
20263
20264
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.cont_heart,f))
20265 {
20266 return qe_invalid;
20267 }
20268 }
20269
20270
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.hcp,f))
20271 {
20272 return qe_invalid;
20273 }
20274
20275
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version >= 14)
20276 {
20277
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20278 {
20279 return qe_invalid;
20280 }
20281
20282
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(s_version<16) // July 2007
20283 {
20284 if(get_qr(qr_BRANGPICKUP+1))
20285 temp_zinit.hcp_per_hc = 0xFF;
20286
20287 //Dispose of legacy rule
20288 set_qr(qr_BRANGPICKUP+1, 0);
20289 }
20290 217 }
20291
20292
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20293 {
20294
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20295 return qe_invalid;
20296 264 temp_zinit.mcounter[crBOMBS] = padding;
20297 264 }
20298
20299
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20300 {
20301 return qe_invalid;
20302 }
20303
20304
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20305 {
20306 return qe_invalid;
20307 }
20308
20309
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20310 return qe_invalid;
20311
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 281 times.
2529 for(int q = 0; q < 8; ++q)
20312
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1744 times.
2248 SETFLAG(temp_zinit.litems[q+1], (1 << li_mcguffin), get_bitl(tempbyte, q));
20313
20314 281 int level_count = 32;
20315
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20316 217 level_count = 64;
20317 byte tmp_map[64];
20318 byte tmp_compass[64];
20319
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20320
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_map[i],f))
20321 return qe_invalid;
20322
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20323
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_compass[i],f))
20324 return qe_invalid;
20325
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 281 times.
127769 for(int q = 0; q < level_count*8; ++q)
20326 {
20327
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 126692 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
20328
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 127479 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
20329 127488 }
20330
20331
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20332 //new only
20333
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20334 {
20335 byte tmp_boss_key[64];
20336
2/2
✓ Branch 0 taken 15808 times.
✓ Branch 1 taken 277 times.
16085 for(int32_t i=0; i<level_count; i++)
20337 {
20338
1/2
✓ Branch 0 taken 15808 times.
✗ Branch 1 not taken.
15808 if(!p_getc(&tmp_boss_key[i],f))
20339 {
20340 return qe_invalid;
20341 }
20342 15808 }
20343
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 277 times.
126741 for(int q = 0; q < level_count*8; ++q)
20344 {
20345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126464 times.
126464 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20346 126464 }
20347 277 }
20348
20349 byte tmpmisc[16];
20350
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 281 times.
4777 for(int32_t i=0; i<16; i++)
20351
1/2
✓ Branch 0 taken 4496 times.
✗ Branch 1 not taken.
4496 if(!p_getc(&tmpmisc[i],f))
20352 return qe_invalid;
20353 281 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20354 281 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20355 281 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20356
20357
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
537 if(s_version < 15) for(int32_t i=0; i<4; i++)
20358
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20359 64 return qe_invalid;
20360
20361
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_map,f))
20362 {
20363 return qe_invalid;
20364 }
20365
20366
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_screen,f))
20367 {
20368 return qe_invalid;
20369 }
20370
20371
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20372 {
20373 byte tempmp;
20374
20375
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20376 {
20377 return qe_invalid;
20378 }
20379
20380 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20381
20382
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20383 {
20384 return qe_invalid;
20385 }
20386
20387 64 temp_zinit.counter[crMAGIC]=tempmp;
20388 64 }
20389 else
20390 {
20391
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20392 {
20393 return qe_invalid;
20394 }
20395
20396
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20397 {
20398 return qe_invalid;
20399 }
20400 }
20401
20402
20403
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 15)
20404 {
20405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20406 {
20407 64 temp_zinit.mcounter[crMAGIC]*=32;
20408 64 temp_zinit.counter[crMAGIC]*=32;
20409 64 }
20410
20411
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20412 {
20413
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20414 {
20415 return qe_invalid;
20416 }
20417 256 }
20418
20419
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20420 {
20421 return qe_invalid;
20422 }
20423 64 }
20424 else
20425 {
20426
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.bomb_ratio,f))
20427 return qe_invalid;
20428
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(temp_zinit.bomb_ratio < 1)
20429 temp_zinit.bomb_ratio = 1;
20430 217 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20431 }
20432
20433
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 15)
20434 {
20435 byte tempbp;
20436
20437
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20438 {
20439
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20440 {
20441 return qe_invalid;
20442 }
20443
20444 256 beam_power[i]=tempbp;
20445 256 }
20446
20447
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20448 {
20449 return qe_invalid;
20450 }
20451
20452
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20453 {
20454 if(!p_getc(&hookshot_length,f))
20455 {
20456 return qe_invalid;
20457 }
20458
20459 if(!p_getc(&longshot_links,f))
20460 {
20461 return qe_invalid;
20462 }
20463
20464 if(!p_getc(&longshot_length,f))
20465 {
20466 return qe_invalid;
20467 }
20468 }
20469 64 }
20470
20471
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_x,f))
20472 {
20473 return qe_invalid;
20474 }
20475
20476
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_y,f))
20477 {
20478 return qe_invalid;
20479 }
20480
20481
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&subscr_mode,f))
20482 return qe_invalid;
20483
20484 //old only
20485
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20486 {
20487 byte tmp_boss_key[32];
20488
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20489 {
20490
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20491 {
20492 return qe_invalid;
20493 }
20494 128 }
20495
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20496 {
20497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20498 1024 }
20499 4 }
20500
20501
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
281 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20502 {
20503
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 217 times.
277 if(s_version <= 10)
20504 {
20505
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20506 {
20507 return qe_invalid;
20508 }
20509
20510 60 temp_zinit.start_dmap = (word)tempbyte;
20511 60 }
20512 else
20513 {
20514
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.start_dmap,f))
20515 {
20516 return qe_invalid;
20517 }
20518 }
20519
20520
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20521 {
20522 return qe_invalid;
20523 }
20524 277 }
20525
20526
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 200 times.
281 if(s_version>1 && s_version < 29)
20527 {
20528
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20529 return qe_invalid;
20530 200 temp_zinit.counter[crARROWS] = padding;
20531
20532
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20533 return qe_invalid;
20534 200 temp_zinit.mcounter[crARROWS] = padding;
20535 200 }
20536
20537
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>2)
20538 {
20539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(s_version <= 10)
20540 {
20541 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20542 {
20543 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20544 {
20545 return qe_invalid;
20546 }
20547 }
20548 }
20549 else
20550 {
20551
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 217 times.
111321 for(int32_t i=0; i<MAXLEVELS; i++)
20552 {
20553
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20554 {
20555 return qe_invalid;
20556 }
20557 111104 }
20558 }
20559 217 }
20560
20561
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>3)
20562 {
20563
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20564 {
20565 return qe_invalid;
20566 }
20567
20568
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20569 {
20570 return qe_invalid;
20571 }
20572
20573
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20574 {
20575 return qe_invalid;
20576 }
20577
20578
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20579 {
20580 return qe_invalid;
20581 }
20582
20583
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20584 {
20585 return qe_invalid;
20586 }
20587
20588
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20589 {
20590 return qe_invalid;
20591 }
20592
20593
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20594 {
20595 return qe_invalid;
20596 }
20597
20598
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_flags,f))
20599 {
20600 return qe_invalid;
20601 }
20602
20603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20605 217 }
20606
20607
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>4 && s_version<15)
20608 {
20609 if(!p_getc(&moving_fairy_hearts,f))
20610 {
20611 return qe_invalid;
20612 }
20613
20614 if(!p_getc(&moving_fairy_heart_percent,f))
20615 {
20616 return qe_invalid;
20617 }
20618 }
20619
20620
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>5 && s_version < 10)
20621 {
20622 if(!p_getc(&temp,f))
20623 {
20624 return qe_invalid;
20625 }
20626
20627 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20628 }
20629
20630
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>6 && s_version<15)
20631 {
20632 if(!p_getc(&stationary_fairy_hearts,f))
20633 {
20634 return qe_invalid;
20635 }
20636
20637 if(!p_getc(&stationary_fairy_heart_percent,f))
20638 {
20639 return qe_invalid;
20640 }
20641
20642 if(!p_getc(&moving_fairy_magic,f))
20643 {
20644 return qe_invalid;
20645 }
20646
20647 if(!p_getc(&moving_fairy_magic_percent,f))
20648 {
20649 return qe_invalid;
20650 }
20651
20652 if(!p_getc(&stationary_fairy_magic,f))
20653 {
20654 return qe_invalid;
20655 }
20656
20657 if(!p_getc(&stationary_fairy_magic_percent,f))
20658 {
20659 return qe_invalid;
20660 }
20661
20662 if(!p_getc(&blue_potion_hearts,f))
20663 {
20664 return qe_invalid;
20665 }
20666
20667 if(!p_getc(&blue_potion_heart_percent,f))
20668 {
20669 return qe_invalid;
20670 }
20671
20672 if(!p_getc(&red_potion_hearts,f))
20673 {
20674 return qe_invalid;
20675 }
20676
20677 if(!p_getc(&red_potion_heart_percent,f))
20678 {
20679 return qe_invalid;
20680 }
20681
20682 if(!p_getc(&blue_potion_magic,f))
20683 {
20684 return qe_invalid;
20685 }
20686
20687 if(!p_getc(&blue_potion_magic_percent,f))
20688 {
20689 return qe_invalid;
20690 }
20691
20692 if(!p_getc(&red_potion_magic,f))
20693 {
20694 return qe_invalid;
20695 }
20696
20697 if(!p_getc(&red_potion_magic_percent,f))
20698 {
20699 return qe_invalid;
20700 }
20701 }
20702
20703
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>6)
20704
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20705 return qe_invalid;
20706
20707
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>7)
20708 {
20709
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20710 {
20711 return qe_invalid;
20712 }
20713 217 }
20714
20715
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>8)
20716 {
20717
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20718 {
20719 return qe_invalid;
20720 }
20721
20722
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20723 {
20724 return qe_invalid;
20725 }
20726 217 }
20727
20728
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version>16)
20729 {
20730
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&tempbyte,f))
20731 {
20732 return qe_invalid;
20733 }
20734 217 temp_zinit.gravity = tempbyte*100;
20735
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.terminalv,f))
20736 {
20737 return qe_invalid;
20738 }
20739
20740
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_speed,f))
20741 {
20742 return qe_invalid;
20743 }
20744
20745
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20746 {
20747 return qe_invalid;
20748 }
20749
20750
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20751 {
20752 return qe_invalid;
20753 }
20754 217 }
20755
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20756 12 temp_zinit.msg_speed = 0;
20757
20758
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>17)
20759 {
20760
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20761 {
20762 return qe_invalid;
20763 }
20764 217 }
20765
20766 //expaned init data for larger values in 2.55
20767
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 17 times.
281 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20768 {
20769
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20770 {
20771 return qe_invalid;
20772 }
20773
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20774 {
20775 return qe_invalid;
20776 }
20777
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20778 {
20779 return qe_invalid;
20780 }
20781
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20782 {
20783 return qe_invalid;
20784 }
20785
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20786 {
20787 return qe_invalid;
20788 }
20789
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20790 {
20791 return qe_invalid;
20792 }
20793
20794 17 }
20795
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 20 )
20796 {
20797
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20798 {
20799 return qe_invalid;
20800 }
20801 17 }
20802 else
20803 {
20804 264 temp_zinit.heroStep = 150; //1.5 pixels per frame
20805 }
20806
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 21 )
20807 {
20808
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20809 {
20810 return qe_invalid;
20811 }
20812 17 }
20813 else
20814 {
20815 264 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20816 }
20817 //old only
20818
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20819 {
20820 byte items2;
20821
20822
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20823 {
20824 return qe_invalid;
20825 }
20826
20827 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20828 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20829 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20830 4 }
20831
20832
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5 times.
281 if(Header->zelda_version < 0x193)
20833 {
20834
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20835 {
20836
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20837 {
20838 return qe_invalid;
20839 }
20840 480 }
20841
20842 //new only
20843
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20844 {
20845
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20846 {
20847 return qe_invalid;
20848 }
20849
20850
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20851 {
20852 return qe_invalid;
20853 }
20854 1 }
20855 5 }
20856 281 }
20857
20858
3/6
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20859 {
20860 //temp_zinit.shield=i_smallshield;
20861 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20862
20863
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20864 82 temp_zinit.set_item(sshieldid, true);
20865 82 }
20866
20867
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20868 {
20869 18 temp_zinit.mcounter[crLIFE]=3;
20870 18 temp_zinit.counter[crLIFE]=3;
20871 18 temp_zinit.cont_heart=3;
20872 18 temp_zinit.mcounter[crBOMBS]=8;
20873 18 }
20874
20875
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20876 {
20877 18 sword_hearts[0]=0;
20878 18 sword_hearts[1]=5;
20879 18 sword_hearts[2]=12;
20880 18 sword_hearts[3]=21;
20881 18 }
20882
20883
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20884 {
20885 18 temp_zinit.last_map=0;
20886 18 temp_zinit.last_screen=0;
20887 18 }
20888
20889
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20890 {
20891 18 temp_zinit.mcounter[crMAGIC]=0;
20892 18 temp_zinit.counter[crMAGIC]=0;
20893 18 temp_zinit.magicdrainrate = 2;
20894 18 }
20895
20896
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20897 {
20898
20899
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20900 {
20901 72 beam_hearts[x]=100;
20902 72 }
20903
20904
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20905 {
20906 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20907 72 set_qr(qr_LENSHINTS+i,0);
20908 72 }
20909
20910
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20911 {
20912 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20913 72 }
20914
20915 18 set_qr(qr_HIDECARRIEDITEMS,0);
20916 18 hookshot_links=100;
20917 18 temp_zinit.msg_more_x=224;
20918 18 temp_zinit.msg_more_y=64;
20919 18 }
20920
20921 // Okay, let's put these legacy values into itemsbuf.
20922
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 15)
20923
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20924 {
20925
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20926 {
20927 case iFairyStill:
20928 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20929 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20930 82 itemsbuf[i].misc3 = 0;
20931
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20932
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20933 82 break;
20934
20935 case iFairyMoving:
20936 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20937 82 itemsbuf[i].misc2 = moving_fairy_magic;
20938 82 itemsbuf[i].misc3 = 50;
20939
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20940
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20941 82 break;
20942
20943 case iRPotion:
20944 82 itemsbuf[i].misc1 = red_potion_hearts;
20945 82 itemsbuf[i].misc2 = red_potion_magic;
20946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20948 82 break;
20949
20950 case iBPotion:
20951 82 itemsbuf[i].misc1 = blue_potion_hearts;
20952 82 itemsbuf[i].misc2 = blue_potion_magic;
20953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20955 82 break;
20956
20957 case iSword:
20958 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20959 82 itemsbuf[i].misc1 = beam_hearts[0];
20960 82 itemsbuf[i].misc2 = beam_power[0];
20961 // It seems that item_flag1 was already added by reset_itembuf()...
20962 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20963 82 break;
20964
20965 case iWSword:
20966 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20967 82 itemsbuf[i].misc1 = beam_hearts[1];
20968 82 itemsbuf[i].misc2 = beam_power[1];
20969 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20970 82 break;
20971
20972 case iMSword:
20973 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20974 82 itemsbuf[i].misc1 = beam_hearts[2];
20975 82 itemsbuf[i].misc2 = beam_power[2];
20976 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20977 82 break;
20978
20979 case iXSword:
20980 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20981 82 itemsbuf[i].misc1 = beam_hearts[3];
20982 82 itemsbuf[i].misc2 = beam_power[3];
20983 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20984 82 break;
20985
20986 case iHookshot:
20987 82 itemsbuf[i].misc1 = hookshot_length;
20988 82 itemsbuf[i].misc2 = hookshot_links;
20989 82 break;
20990
20991 case iLongshot:
20992 82 itemsbuf[i].misc1 = longshot_length;
20993 82 itemsbuf[i].misc2 = longshot_links;
20994 82 break;
20995 }
20996 21074 }
20997
20998
6/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20999 {
21000 //was new subscreen rule
21001 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
21002 22 set_qr(qr_FREEFORM,0);
21003 22 }
21004
21005
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
21006 {
21007 23 temp_zinit.start_dmap=0;
21008 23 }
21009
21010
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
21011 {
21012 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
21013 23 }
21014
21015
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
299 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
21016 {
21017 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
21018 temp_zinit.mcounter[crMONEY]=999;
21019 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
21020 }
21021
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
21022 {
21023 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
21024 6 temp_zinit.mcounter[crBOMBS] = 8;
21025 6 }
21026 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
21027 //time to ensure that we port all new values properly:
21028
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(Header->zelda_version < 0x250)
21029 {
21030
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
21031 82 }
21032
21033
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 21)
21034 {
21035
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
21036 {
21037 return qe_invalid;
21038 }
21039
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
21040 {
21041 return qe_invalid;
21042 }
21043
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21044 {
21045 return qe_invalid;
21046 }
21047
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21048 {
21049 return qe_invalid;
21050 }
21051 17 }
21052 else
21053 {
21054 282 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
21055 282 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
21056 282 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
21057 282 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
21058 }
21059
21060
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 22)
21061 {
21062
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
21064 return qe_invalid;
21065
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
21067 return qe_invalid;
21068 17 }
21069
21070
21071
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 23)
21072 {
21073
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
21074 {
21075 return qe_invalid;
21076 }
21077
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
21078 {
21079 return qe_invalid;
21080 }
21081
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
21082 {
21083 return qe_invalid;
21084 }
21085
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
21086 {
21087 return qe_invalid;
21088 }
21089
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
21090 {
21091 return qe_invalid;
21092 }
21093 17 }
21094 else
21095 {
21096 282 temp_zinit.dither_type = 0;
21097 282 temp_zinit.dither_arg = 0;
21098 282 temp_zinit.dither_percent = 20;
21099 282 temp_zinit.def_lightrad = 24;
21100 282 temp_zinit.transdark_percent = 0;
21101 }
21102
21103
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 24)
21104 {
21105
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
21106 {
21107 return qe_invalid;
21108 }
21109 17 }
21110 else
21111 {
21112 282 temp_zinit.darkcol = BLACK;
21113 }
21114
21115
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 25)
21116 {
21117
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
21118 {
21119 return qe_invalid;
21120 }
21121
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
21122 {
21123 return qe_invalid;
21124 }
21125 17 }
21126
21127
21128
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 26)
21129 {
21130
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21131 {
21132 return qe_invalid;
21133 }
21134
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21135 {
21136 return qe_invalid;
21137 }
21138
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21139 {
21140 return qe_invalid;
21141 }
21142 17 }
21143 else
21144 {
21145 282 temp_zinit.heroSideswimUpStep = 150;
21146 282 temp_zinit.heroSideswimSideStep = 100;
21147 282 temp_zinit.heroSideswimDownStep = 75;
21148 }
21149
21150
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 27)
21151 {
21152
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21153 {
21154 return qe_invalid;
21155 }
21156 17 }
21157 else
21158 {
21159 282 temp_zinit.exitWaterJump = 0;
21160 }
21161
21162
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 29)
21163 {
21164
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21165 {
21166 return qe_invalid;
21167 }
21168 17 }
21169 else
21170 {
21171 282 temp_zinit.bunny_ltm = 0;
21172 }
21173
21174
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 30)
21175 {
21176
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
21177 {
21178 return qe_invalid;
21179 }
21180 17 }
21181 else
21182 {
21183 282 temp_zinit.switchhookstyle = 1;
21184 }
21185
21186
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 31)
21187 {
21188
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21189 {
21190 return qe_invalid;
21191 }
21192 17 }
21193
21194 299 temp_zinit.clear_genscript();
21195
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 12 times.
299 if(s_version > 32)
21196 {
21197 12 word numgenscript = 0;
21198
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21199 return qe_invalid;
21200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21201 return qe_invalid;
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21203 {
21204 if(!p_getc(&tempbyte,f))
21205 return qe_invalid;
21206 if(!(tempbyte&2))
21207 continue;
21208 temp_zinit.gen_doscript.set(q, tempbyte&1);
21209 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21210 return qe_invalid;
21211 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21212 return qe_invalid;
21213 for(auto p = 0; p < 8; ++p)
21214 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21215 return qe_invalid;
21216 dword sz;
21217 if(!p_igetl(&sz,f))
21218 return qe_invalid;
21219 temp_zinit.gen_data[q].resize(sz);
21220 std::vector<int32_t> dummy;
21221 if(!p_getlvec(&dummy,f))
21222 return qe_invalid;
21223 temp_zinit.gen_data[q] = dummy;
21224 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21225 return qe_invalid;
21226 }
21227 12 }
21228
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(s_version > 33)
21229 {
21230
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21231 return qe_invalid;
21232
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21233 return qe_invalid;
21234 6 }
21235
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(s_version > 34)
21236 {
21237 uint32_t num_used_mapscr_data;
21238 if(!p_igetl(&num_used_mapscr_data,f))
21239 return qe_invalid;
21240 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21241 {
21242 uint32_t sz;
21243 if(!p_igetl(&sz,f))
21244 return qe_invalid;
21245 temp_zinit.screen_data[q].resize(sz);
21246 if(sz)
21247 {
21248 std::vector<int32_t> dummy;
21249 if(!p_getlvec(&dummy,f))
21250 return qe_invalid;
21251 temp_zinit.screen_data[q] = dummy;
21252 }
21253 }
21254 }
21255
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if (s_version > 35)
21256 if(!p_igetzf(&temp_zinit.shove_offset,f))
21257 return qe_invalid;
21258
21259 299 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21260 299 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21261
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 110 times.
299 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21262 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21263
21264 299 return 0;
21265 299 }
21266 492 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21267 {
21268 492 zinitdata temp_zinit = {};
21269
21270
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
492 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21271
21272 int32_t dummy;
21273 492 word s_version=0;
21274 byte padding;
21275
21276
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 23 times.
492 if(Header->zelda_version > 0x192)
21277 {
21278
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetw(&s_version,f))
21279 return qe_invalid;
21280
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (s_version > V_INITDATA)
21281 return qe_version;
21282 469 FFCore.quest_format[vInitData] = s_version;
21283
21284
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 if(!read_deprecated_section_cversion(f))
21285 return qe_invalid;
21286
21287 //section size
21288
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!p_igetl(&dummy,f))
21289 return qe_invalid;
21290 469 }
21291
21292
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 193 times.
492 if(s_version < 37)
21293 {
21294
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21295 return ret;
21296 299 }
21297 else
21298 {
21299 193 subscr_mode = ssdtMAX;
21300
2/2
✓ Branch 0 taken 6176 times.
✓ Branch 1 taken 193 times.
6369 for(int q = 0; q < MAXITEMS/8; ++q)
21301
2/4
✓ Branch 0 taken 6176 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6176 times.
6176 if(!p_getc(&temp_zinit.items[q], f))
21302 return qe_invalid;
21303
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 28 times.
193 if(s_version >= 42)
21304 {
21305
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 165 times.
84645 for(int q = 0; q < MAXLEVELS; ++q)
21306 {
21307
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 75776 times.
84480 if (s_version >= 44)
21308 {
21309
2/4
✓ Branch 0 taken 75776 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75776 times.
75776 if(!p_igetw(&temp_zinit.litems[q], f))
21310 return qe_invalid;
21311 75776 }
21312 else
21313 {
21314
2/4
✓ Branch 0 taken 8704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8704 times.
8704 if(!p_getc(&padding, f))
21315 return qe_invalid;
21316 8704 temp_zinit.litems[q] = word(padding);
21317 }
21318 84480 }
21319 165 }
21320 else
21321 {
21322 byte tmp_map[MAXLEVELS/8];
21323 byte tmp_compass[MAXLEVELS/8];
21324 byte tmp_boss_key[MAXLEVELS/8];
21325 byte tmp_mcguffin[MAXLEVELS/8];
21326
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 28 times.
1820 for(int q = 0; q < MAXLEVELS/8; ++q)
21327 {
21328
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1792 times.
✗ Branch 3 not taken.
1792 if(!p_getc(&tmp_map[q], f))
21329 return qe_invalid;
21330
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1792 times.
1792 if(!p_getc(&tmp_compass[q], f))
21331 return qe_invalid;
21332
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1792 times.
1792 if(!p_getc(&tmp_boss_key[q], f))
21333 return qe_invalid;
21334
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1792 times.
✗ Branch 3 not taken.
1792 if(!p_getc(&tmp_mcguffin[q], f))
21335 return qe_invalid;
21336 1792 }
21337
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 28 times.
14364 for(int q = 0; q < MAXLEVELS; ++q)
21338 {
21339
2/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14336 times.
✗ Branch 3 not taken.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
21340
3/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 14316 times.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
21341
2/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14336 times.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
21342
2/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14336 times.
✗ Branch 3 not taken.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_mcguffin), get_bit(tmp_mcguffin, q));
21343 14336 }
21344 }
21345
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbvec(&temp_zinit.level_keys, f))
21346 return qe_invalid;
21347 byte num_counters;
21348
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&num_counters,f))
21349 return qe_invalid;
21350
2/2
✓ Branch 0 taken 20651 times.
✓ Branch 1 taken 193 times.
20844 for(int q = 0; q < num_counters; ++q)
21351
2/4
✓ Branch 0 taken 20651 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20651 times.
20651 if(!p_igetw(&temp_zinit.counter[q],f))
21352 return qe_invalid;
21353
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 20651 times.
20844 for(int q = 0; q < num_counters; ++q)
21354
2/4
✓ Branch 0 taken 20651 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20651 times.
20651 if(!p_igetw(&temp_zinit.mcounter[q],f))
21355 return qe_invalid;
21356
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.bomb_ratio,f))
21357 return qe_invalid;
21358
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hcp,f))
21359 return qe_invalid;
21360
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21361 return qe_invalid;
21362
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_igetw(&temp_zinit.cont_heart,f))
21363 return qe_invalid;
21364
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hp_per_heart,f))
21365 return qe_invalid;
21366
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_getc(&temp_zinit.magic_per_block,f))
21367 return qe_invalid;
21368
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21369 return qe_invalid;
21370
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21371 return qe_invalid;
21372
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.dither_type,f))
21373 return qe_invalid;
21374
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.dither_arg,f))
21375 return qe_invalid;
21376
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_getc(&temp_zinit.dither_percent,f))
21377 return qe_invalid;
21378
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.def_lightrad,f))
21379 return qe_invalid;
21380
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.transdark_percent,f))
21381 return qe_invalid;
21382
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.darkcol,f))
21383 return qe_invalid;
21384
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21385 return qe_invalid;
21386
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21387 return qe_invalid;
21388
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21389 return qe_invalid;
21390
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21391 return qe_invalid;
21392
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21393 return qe_invalid;
21394
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21395 return qe_invalid;
21396
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21397 return qe_invalid;
21398
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.ss_flags,f))
21399 return qe_invalid;
21400
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbitstr(&temp_zinit.flags,f))
21401 return qe_invalid;
21402
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_getc(&temp_zinit.last_map,f))
21403 return qe_invalid;
21404
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.last_screen,f))
21405 return qe_invalid;
21406
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.msg_more_x,f))
21407 return qe_invalid;
21408
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.msg_more_y,f))
21409 return qe_invalid;
21410
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21411 return qe_invalid;
21412
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.msg_speed,f))
21413 return qe_invalid;
21414
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.gravity,f))
21415 return qe_invalid;
21416
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.swimgravity,f))
21417 return qe_invalid;
21418
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.terminalv,f))
21419 return qe_invalid;
21420
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21421 return qe_invalid;
21422
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21423 return qe_invalid;
21424
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.hero_swim_div,f))
21425 return qe_invalid;
21426
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21427 return qe_invalid;
21428
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21429 return qe_invalid;
21430
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21431 return qe_invalid;
21432
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21433 return qe_invalid;
21434
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.heroStep,f))
21435 return qe_invalid;
21436
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21437 return qe_invalid;
21438
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21439 return qe_invalid;
21440
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21441 return qe_invalid;
21442
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.start_dmap,f))
21443 return qe_invalid;
21444
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21445 return qe_invalid;
21446
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.switchhookstyle,f))
21447 return qe_invalid;
21448
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&temp_zinit.magicdrainrate,f))
21449 return qe_invalid;
21450
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetzf(&temp_zinit.shove_offset,f))
21451 return qe_invalid;
21452
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21453 return qe_invalid;
21454
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21455 return qe_invalid;
21456
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21457 return qe_invalid;
21458
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
193 if(!p_getbmap(&temp_zinit.gen_initd, f))
21459 return qe_invalid;
21460
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21461 return qe_invalid;
21462
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbmap(&temp_zinit.gen_data, f))
21463 return qe_invalid;
21464
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getbmap(&temp_zinit.screen_data, f))
21465 return qe_invalid;
21466
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if (s_version >= 38)
21467 {
21468
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21469 return qe_invalid;
21470
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21471 return qe_invalid;
21472
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21473 return qe_invalid;
21474 193 }
21475
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 28 times.
193 if(s_version >= 39)
21476
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetzf(&temp_zinit.air_drag, f))
21477 return qe_invalid;
21478
21479 // TODO: this first branch can likely be removed, as it only fixes an issues
21480 // that existed for a handful of temporary z3 builds (and active users of that
21481 // fork would have been updating often, beyond s_version 40).
21482
3/4
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 165 times.
193 if (Header->is_z3 && s_version == 40)
21483 {
21484 if(!p_getc(&temp_zinit.region_mapping, f))
21485 return qe_invalid;
21486 }
21487 else
21488 {
21489
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 28 times.
193 if(s_version >= 40)
21490 {
21491
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21492 return qe_invalid;
21493
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.light_wave_size, f))
21494 return qe_invalid;
21495 165 }
21496
21497
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 28 times.
193 if(s_version >= 41)
21498 {
21499
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.region_mapping, f))
21500 return qe_invalid;
21501 165 }
21502 }
21503
21504
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 159 times.
193 if(s_version >= 43)
21505
2/2
✓ Branch 0 taken 40704 times.
✓ Branch 1 taken 159 times.
40863 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21506
2/4
✓ Branch 0 taken 40704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40704 times.
✗ Branch 3 not taken.
40704 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21507 159 return qe_invalid;
21508
21509
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 45 times.
193 if(s_version >= 44)
21510
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if (!p_getbvec(&temp_zinit.lvlswitches, f))
21511 return qe_invalid;
21512
21513
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 45 times.
193 if (s_version >= 45)
21514 {
21515
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if (!p_igetw(&temp_zinit.item_spawn_flicker, f))
21516 return qe_invalid;
21517
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if (!p_igetw(&temp_zinit.item_timeout_dur, f))
21518 return qe_invalid;
21519
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if (!p_igetw(&temp_zinit.item_timeout_flicker, f))
21520 return qe_invalid;
21521
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if (!p_getc(&temp_zinit.item_flicker_speed, f))
21522 return qe_invalid;
21523 148 }
21524
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 148 times.
193 if(s_version >= 46)
21525 {
21526
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 148 times.
888 for(int q = 0; q < SPRITE_THRESHOLD_MAX; ++q)
21527
2/4
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 740 times.
✗ Branch 3 not taken.
740 if(!p_igetw(&temp_zinit.sprite_z_thresholds[q], f))
21528 return qe_invalid;
21529 148 }
21530 }
21531
21532
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 344 times.
492 if(s_version < 46)
21533 {
21534 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_GROUND] = temp_zinit.jump_hero_layer_threshold;
21535 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_3] = temp_zinit.jump_hero_layer_threshold;
21536 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_4] = temp_zinit.jump_hero_layer_threshold;
21537 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_OVERHEAD] = word(-1);
21538 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_5] = word(-1);
21539 344 }
21540
21541
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if (should_skip)
21542 return 0;
21543
21544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(loading_tileset_flags & TILESET_CLEARMAPS)
21545 {
21546 temp_zinit.last_map = 0;
21547 temp_zinit.last_screen = 0;
21548 temp_zinit.screen_data.clear();
21549 }
21550
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 temp_zinit.normalize();
21551
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 zinit = temp_zinit;
21552
21553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(zinit.heroAnimationStyle==las_zelda3slow)
21554 {
21555 hero_animation_speed=2;
21556 }
21557 else
21558 {
21559 492 hero_animation_speed=1;
21560 }
21561
21562 492 return 0;
21563 492 }
21564
21565 /*
21566 void setupitemdropsets()
21567 {
21568 for(int32_t i=0; i<isMAX; i++)
21569 {
21570 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21571 }
21572 }
21573 */
21574
21575 433 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21576 {
21577
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 23 times.
433 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21578
21579 dword dummy_dword;
21580 433 word item_drop_sets_to_read=0;
21581 item_drop_object tempitemdrop;
21582 433 word s_version=0;
21583
21584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if (!should_skip)
21585
2/2
✓ Branch 0 taken 110848 times.
✓ Branch 1 taken 433 times.
111281 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21586 {
21587 110848 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21588 111281 }
21589
21590
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 23 times.
433 if(version > 0x192)
21591 {
21592 410 item_drop_sets_to_read=0;
21593
21594 //section version info
21595
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&s_version,f))
21596 {
21597 return qe_invalid;
21598 }
21599
21600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_ITEMDROPSETS)
21601 return qe_version;
21602
21603 410 FFCore.quest_format[vItemDropsets] = s_version;
21604
21605
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
21606 {
21607 return qe_invalid;
21608 }
21609
21610 //section size
21611
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&dummy_dword,f))
21612 {
21613 return qe_invalid;
21614 }
21615
21616 //finally... section data
21617
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&item_drop_sets_to_read,f))
21618 {
21619 return qe_invalid;
21620 }
21621
21622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21623 {
21624 return qe_invalid;
21625 }
21626 410 }
21627 else
21628 {
21629 23 init_item_drop_sets();
21630 }
21631
21632
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 410 times.
433 if(s_version>=1)
21633 {
21634
2/2
✓ Branch 0 taken 6322 times.
✓ Branch 1 taken 410 times.
6732 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21635 {
21636
1/2
✓ Branch 0 taken 6322 times.
✗ Branch 1 not taken.
6322 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21637 {
21638 return qe_invalid;
21639 }
21640
21641
2/2
✓ Branch 0 taken 63220 times.
✓ Branch 1 taken 6322 times.
69542 for(int32_t j=0; j<10; ++j)
21642 {
21643
1/2
✓ Branch 0 taken 63220 times.
✗ Branch 1 not taken.
63220 if(!p_igetw(&tempitemdrop.item[j],f))
21644 {
21645 return qe_invalid;
21646 }
21647 63220 }
21648
21649
2/2
✓ Branch 0 taken 69542 times.
✓ Branch 1 taken 6322 times.
75864 for(int32_t j=0; j<11; ++j)
21650 {
21651
1/2
✓ Branch 0 taken 69542 times.
✗ Branch 1 not taken.
69542 if(!p_igetw(&tempitemdrop.chance[j],f))
21652 {
21653 return qe_invalid;
21654 }
21655 69542 }
21656
21657 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21658 // overrides the quest's set #12.
21659
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6322 if(s_version<2 && i==12)
21660 continue;
21661
21662 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21663
1/4
✓ Branch 0 taken 6322 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6322 if(s_version<2) for(int32_t j=0; j<10; ++j)
21664 {
21665 int32_t it = tempitemdrop.item[j];
21666
21667 if((itemsbuf[it].type == itype_rupee
21668 && ((itemsbuf[it].amount)&0xFFF) == 10)
21669 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21670 {
21671 tempitemdrop.chance[j+1]=0;
21672 }
21673 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21674 {
21675 tempitemdrop.chance[j+1]=0;
21676 }
21677
21678 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21679 if(itemsbuf[it].type == itype_misc)
21680 {
21681 // If a non-gameplay item was selected, then item drop was aborted.
21682 // Reflect this by increasing the 'Nothing' chance accordingly.
21683 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21684 tempitemdrop.chance[j+1]=0;
21685 }
21686 }
21687
21688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6322 times.
6322 if (!should_skip)
21689 6322 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21690 6322 }
21691 410 }
21692
21693 433 return 0;
21694 433 }
21695
21696 410 int32_t readfavorites(PACKFILE *f, int32_t)
21697 {
21698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21699
21700 int32_t temp_num;
21701 dword dummy_dword;
21702 word num_favorite_combos;
21703 word num_favorite_combo_aliases;
21704 410 word s_version=0;
21705
21706 //section version info
21707
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&s_version,f))
21708 {
21709 return qe_invalid;
21710 }
21711
21712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (s_version > V_FAVORITES)
21713 return qe_version;
21714
21715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (!should_skip)
21716 410 FFCore.quest_format[vFavourites] = s_version;
21717
21718
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!read_deprecated_section_cversion(f))
21719 {
21720 return qe_invalid;
21721 }
21722
21723 //section size
21724
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetl(&dummy_dword,f))
21725 {
21726 return qe_invalid;
21727 }
21728
21729 410 word per_row = FAVORITECOMBO_PER_ROW;
21730 410 word per_page = FAVORITECOMBO_PER_PAGE;
21731
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 199 times.
410 if(s_version >= 3)
21732
1/2
✓ Branch 0 taken 199 times.
✗ Branch 1 not taken.
199 if(!p_igetw(&per_row,f))
21733 return qe_invalid;
21734
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 193 times.
410 if(s_version >= 4)
21735
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_igetw(&per_page,f))
21736 return qe_invalid;
21737 //finally... section data
21738
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&num_favorite_combos,f))
21739 {
21740 return qe_invalid;
21741 }
21742
21743 //Hack; port old favorite combos
21744
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
410 if(s_version < 3 && num_favorite_combos == 100)
21745 211 per_row = 13;
21746
21747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (!should_skip)
21748
2/2
✓ Branch 0 taken 516600 times.
✓ Branch 1 taken 410 times.
517010 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21749 517010 favorite_combos[q] = -1;
21750 410 byte favtype = 0;
21751
2/2
✓ Branch 0 taken 28017 times.
✓ Branch 1 taken 410 times.
28427 for(int32_t i=0; i<num_favorite_combos; i++)
21752 {
21753
2/2
✓ Branch 0 taken 6911 times.
✓ Branch 1 taken 21106 times.
28017 if (s_version >= 4)
21754 {
21755
1/2
✓ Branch 0 taken 6911 times.
✗ Branch 1 not taken.
6911 if (!p_getc(&favtype, f))
21756 {
21757 return qe_invalid;
21758 }
21759 6911 }
21760 else
21761 21106 favtype = 0;
21762
1/2
✓ Branch 0 taken 28017 times.
✗ Branch 1 not taken.
28017 if(!p_igetl(&temp_num,f))
21763 {
21764 return qe_invalid;
21765 }
21766
21767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28017 times.
28017 if (should_skip)
21768 continue;
21769
21770
2/2
✓ Branch 0 taken 6911 times.
✓ Branch 1 taken 21106 times.
28017 if(per_row == FAVORITECOMBO_PER_ROW)
21771 {
21772 6911 favorite_combos[i] = temp_num;
21773 6911 favorite_combo_modes[i] = favtype;
21774 6911 }
21775 else
21776 {
21777 21106 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21778 21106 favorite_combos[new_i]=temp_num;
21779 21106 favorite_combo_modes[new_i] = favtype;
21780 }
21781 28017 }
21782
21783 // Discard the separate favorite aliases list from previous versions
21784
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 217 times.
410 if(s_version<4)
21785 {
21786
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (!p_igetw(&num_favorite_combo_aliases, f))
21787 {
21788 return qe_invalid;
21789 }
21790
21791
2/2
✓ Branch 0 taken 21100 times.
✓ Branch 1 taken 217 times.
21317 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21792 {
21793
1/2
✓ Branch 0 taken 21100 times.
✗ Branch 1 not taken.
21100 if (!p_igetl(&temp_num, f))
21794 {
21795 return qe_invalid;
21796 }
21797 21100 }
21798 217 }
21799
21800 410 word max_combo_cols = 0;
21801 410 word max_mappages = 0;
21802
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 199 times.
410 if(s_version >= 2)
21803 {
21804
1/2
✓ Branch 0 taken 199 times.
✗ Branch 1 not taken.
199 if(!p_igetw(&max_combo_cols,f))
21805 return qe_invalid;
21806 199 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21807
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 199 times.
995 for(int q = 0; q < max_combo_cols; ++q)
21808 {
21809
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetl(&tmp,f))
21810 return qe_invalid;
21811
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetl(&tmp2,f))
21812 return qe_invalid;
21813
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetl(&tmp3,f))
21814 return qe_invalid;
21815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if(q < MAX_COMBO_COLS)
21816 {
21817 796 First[q] = tmp;
21818 796 combo_alistpos[q] = tmp2;
21819 796 combo_pool_listpos[q] = tmp3;
21820 796 }
21821 796 }
21822
21823
1/2
✓ Branch 0 taken 199 times.
✗ Branch 1 not taken.
199 if(!p_igetw(&max_mappages,f))
21824 return qe_invalid;
21825
2/2
✓ Branch 0 taken 1791 times.
✓ Branch 1 taken 199 times.
1990 for(int q = 0; q < max_mappages; ++q)
21826 {
21827
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_igetl(&tmp,f))
21828 return qe_invalid;
21829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
1791 if(!p_igetl(&tmp2,f))
21830 return qe_invalid;
21831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
1791 if(q < MAX_MAPPAGE_BTNS)
21832 {
21833 1791 map_page[q].map = tmp;
21834 1791 map_page[q].screen = tmp2;
21835 1791 }
21836 1791 }
21837 199 }
21838
21839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (should_skip)
21840 return 0;
21841
21842
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 410 times.
1254 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21843 {
21844 844 First[q] = 0;
21845 844 combo_alistpos[q] = 0;
21846 844 combo_pool_listpos[q] = 0;
21847 844 }
21848
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 410 times.
2309 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21849 {
21850 1899 map_page[q].map = 0;
21851 1899 map_page[q].screen = 0;
21852 1899 }
21853
21854 410 return 0;
21855 410 }
21856
21857 /*
21858 switch (ret) {
21859 case 0:
21860 break;
21861
21862 case qe_invalid:
21863 goto invalid;
21864 break;
21865 default:
21866 pack_fclose(f);
21867 if(!oldquest)
21868 delete_file(tmpfilename);
21869 return ret;
21870 break;
21871 }
21872 */
21873
21874 const char *skip_text[skip_max]=
21875 {
21876 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21877 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21878 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21879 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21880 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21881 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21882 "skip_favorites"
21883 };
21884
21885
21886 void port250QuestRules(){
21887
21888 portCandleRules(); //Candle
21889 portBombRules();
21890
21891 }
21892
21893 void portCandleRules()
21894 {
21895 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21896 //itemdata itemsbuf;
21897 for ( int32_t q = 0; q < MAXITEMS; q++ )
21898 {
21899 if ( itemsbuf[q].type == itype_candle )
21900 {
21901 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21902 else itemsbuf[q].flags &= ~ item_flag2;
21903 }
21904 }
21905 }
21906
21907 void portBombRules()
21908 {
21909 bool hurtshero = get_qr(qr_OUCHBOMBS);
21910 //itemdata itemsbuf;
21911 for ( int32_t q = 0; q < MAXITEMS; q++ )
21912 {
21913 if ( itemsbuf[q].type == itype_bomb )
21914 {
21915 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21916 else itemsbuf[q].flags &= ~ item_flag2;
21917 }
21918 }
21919 }
21920
21921 19077 static int section_id_to_enum(int id)
21922 {
21923
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 824 times.
✓ Branch 3 taken 824 times.
✓ Branch 4 taken 824 times.
✓ Branch 5 taken 824 times.
✓ Branch 6 taken 741 times.
✓ Branch 7 taken 824 times.
✓ Branch 8 taken 824 times.
✓ Branch 9 taken 824 times.
✓ Branch 10 taken 824 times.
✓ Branch 11 taken 824 times.
✓ Branch 12 taken 824 times.
✓ Branch 13 taken 741 times.
✓ Branch 14 taken 741 times.
✓ Branch 15 taken 824 times.
✓ Branch 16 taken 824 times.
✓ Branch 17 taken 765 times.
✓ Branch 18 taken 741 times.
✓ Branch 19 taken 741 times.
✓ Branch 20 taken 741 times.
✓ Branch 21 taken 824 times.
✓ Branch 22 taken 824 times.
✓ Branch 23 taken 765 times.
✓ Branch 24 taken 741 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
19077 switch (id)
21924 {
21925 case ID_HEADER: return skip_header;
21926 824 case ID_RULES: return skip_rules;
21927 824 case ID_STRINGS: return skip_strings;
21928 824 case ID_MISC: return skip_misc;
21929 824 case ID_TILES: return skip_tiles;
21930 824 case ID_COMBOS: return skip_combos;
21931 741 case ID_COMBOALIASES: return skip_comboaliases;
21932 824 case ID_CSETS: return skip_csets;
21933 824 case ID_MAPS: return skip_maps;
21934 824 case ID_DMAPS: return skip_dmaps;
21935 824 case ID_DOORS: return skip_doors;
21936 824 case ID_ITEMS: return skip_items;
21937 824 case ID_WEAPONS: return skip_weapons;
21938 741 case ID_COLORS: return skip_colors;
21939 741 case ID_ICONS: return skip_icons;
21940 824 case ID_INITDATA: return skip_initdata;
21941 824 case ID_GUYS: return skip_guys;
21942 765 case ID_HEROSPRITES: return skip_herosprites;
21943 741 case ID_SUBSCREEN: return skip_subscreens;
21944 741 case ID_FFSCRIPT: return skip_ffscript;
21945 741 case ID_SFX: return skip_sfx;
21946 824 case ID_MIDIS: return skip_midis;
21947 824 case ID_CHEATS: return skip_cheats;
21948 765 case ID_ITEMDROPSETS: return skip_itemdropsets;
21949 741 case ID_FAVORITES: return skip_favorites;
21950 case ID_ZINFO: return skip_zinfo;
21951 }
21952
21953 return -1;
21954 19077 }
21955
21956 18669 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21957 {
21958 18669 int section_enum = section_id_to_enum(section_id);
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18669 times.
18669 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21960
2/2
✓ Branch 0 taken 6951 times.
✓ Branch 1 taken 11718 times.
18669 if (skip)
21961 {
21962 word s_version;
21963
1/2
✓ Branch 0 taken 6951 times.
✗ Branch 1 not taken.
6951 if (!p_igetw(&s_version,f))
21964 {
21965 return qe_invalid;
21966 }
21967
21968
1/2
✓ Branch 0 taken 6951 times.
✗ Branch 1 not taken.
6951 if (!read_deprecated_section_cversion(f))
21969 {
21970 return qe_invalid;
21971 }
21972
21973
3/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 6620 times.
✓ Branch 2 taken 331 times.
✗ Branch 3 not taken.
6951 if (section_id == ID_RULES && s_version > 16)
21974 {
21975 dword dummy;
21976 if (!p_igetl(&dummy,f))
21977 {
21978 return qe_invalid;
21979 }
21980 }
21981
21982
3/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 6620 times.
✓ Branch 2 taken 331 times.
✗ Branch 3 not taken.
6951 if (section_id == ID_FFSCRIPT && s_version >= 18)
21983 {
21984 word dummy;
21985 if (!p_igetw(&dummy,f))
21986 {
21987 return qe_invalid;
21988 }
21989 }
21990
21991 dword section_length;
21992
1/2
✓ Branch 0 taken 6951 times.
✗ Branch 1 not taken.
6951 if (!p_igetl(&section_length,f))
21993 {
21994 return qe_invalid;
21995 }
21996
21997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6951 times.
6951 if (pack_fseek(f, section_length))
21998 {
21999 return qe_invalid;
22000 }
22001
22002
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 6620 times.
6951 if (!pack_feof(f))
22003 {
22004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6620 times.
6620 if (!p_mgetl(&section_id,f))
22005 {
22006 return qe_invalid;
22007 }
22008 6620 }
22009
22010 6951 return qe_cancel;
22011 }
22012
22013 11718 return qe_OK;
22014 18669 }
22015
22016 // TODO: this was copied from zc/zasm_utils.cpp
22017 282 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
22018 {
22019 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
22020
22021 282 std::vector<zasm_script*> scripts;
22022
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 scripts.reserve(zasm_scripts.size());
22023
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 301585 times.
301867 for (auto& script : zasm_scripts)
22024
2/2
✓ Branch 0 taken 293103 times.
✓ Branch 1 taken 8482 times.
301585 if (script->valid())
22025
1/2
✓ Branch 0 taken 8482 times.
✗ Branch 1 not taken.
8482 scripts.push_back(script.get());
22026
22027
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 282 times.
✗ Branch 3 not taken.
282 std::for_each(scripts.begin(), scripts.end(), fn);
22028 282 }
22029
22030 492 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
22031 {
22032 // 2.55.9 or newer?
22033
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 326 times.
492 if (header.compareVer(2, 55, 9) >= 0)
22034 166 return false; // defer to whatever was set
22035
22036 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
22037
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 276 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 276 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 276 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 288 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
326 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
22038 38 return true;
22039
22040 // Quests prior to 2.55.9 with a scripted subscreen?
22041
2/2
✓ Branch 0 taken 145923 times.
✓ Branch 1 taken 285 times.
146208 for (int i = 0; i < MAXDMAPS; i++)
22042 {
22043 145923 int script = DMaps[i].active_sub_script;
22044
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 145920 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
145923 if (script && dmapscripts[script] && dmapscripts[script]->valid())
22045 3 return true;
22046 145920 }
22047
22048 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
22049
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 std::string title = header.title;
22050
3/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 282 times.
285 if (title == "Yuurand: Tales of the Labyrinth")
22051 3 return true;
22052
22053 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
22054 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
22055 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
22056 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
22057 282 bool found = false;
22058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
8764 _zasm_for_every_script([&](auto script){
22059
2/2
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 5449 times.
8482 if (found) return;
22060
22061
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 23840130 times.
23845549 for (const auto& instr : script->zasm)
22062 {
22063
4/4
✓ Branch 0 taken 20882211 times.
✓ Branch 1 taken 2957919 times.
✓ Branch 2 taken 358211 times.
✓ Branch 3 taken 20524000 times.
23840130 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
22064
22065 3316130 int value = instr.arg2;
22066
9/10
✓ Branch 0 taken 3316128 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3316125 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3316101 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3316101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3316100 times.
3316130 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
22067 {
22068 30 found = true;
22069 30 break;
22070 }
22071 }
22072 8482 });
22073
22074 282 return found;
22075 492 }
22076
22077 static int32_t prev_quest_format[versiontypesLAST];
22078 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
22079 static byte prev_extra_rules[EXTRARULES_SIZE];
22080 static byte prev_midi_flags[MIDIFLAGS_SIZE];
22081 static word prev_map_count;
22082
22083 // When skipping any section, we are loading a qst file just to poke at a couple things.
22084 // We should not mutate important globals in that case.
22085 // We should also restore these globals when loading a qst fails.
22086 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
22087 // (see load_imagebuf).
22088 824 static void store_prev_qstload_global_state()
22089 {
22090 824 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
22091 824 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
22092 824 memcpy(prev_midi_flags, midi_flags, MIDIFLAGS_SIZE);
22093 824 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
22094 824 prev_map_count = map_count;
22095 824 }
22096
22097 332 static void restore_prev_qstload_global_state()
22098 {
22099 332 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
22100 332 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
22101 332 unpack_qrs();
22102 332 memcpy(midi_flags, prev_midi_flags, MIDIFLAGS_SIZE);
22103 332 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
22104 332 map_count = prev_map_count;
22105 332 }
22106
22107 //Internal function for loadquest wrapper
22108 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
22109 824 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
22110 {
22111 824 DMapEditorLastMaptileUsed = 0;
22112 824 combosread=false;
22113 824 mapsread=false;
22114 824 fixffcs=false;
22115
22116 824 store_prev_qstload_global_state();
22117
22118 824 bool skipping_any = false;
22119
2/2
✓ Branch 0 taken 3296 times.
✓ Branch 1 taken 824 times.
4120 for (int i = 0; i < 4; i++)
22120 3296 skipping_any |= skip_flags[i] ? true : false;
22121
22122 824 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
22123
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
22124 {
22125 set_bit(skip_flags, skip_ffscript, 1);
22126 setZScriptVersion(V_FFSCRIPT);
22127 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
22128 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
22129 do_clear_scripts = true;
22130 }
22131
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(loading_tileset_flags & TILESET_CLEARMAPS)
22132 {
22133 set_bit(skip_flags, skip_maps, 1);
22134 }
22135
22136 char tmpfilename[L_tmpnam];
22137 824 temp_name(tmpfilename);
22138 824 bool catchup=false;
22139 byte tempbyte;
22140
22141 // oldquest flag is set when an unencrypted qst file is suspected.
22142 824 bool oldquest = false;
22143 824 int32_t open_error=0;
22144 824 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
22145
22146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if (!f)
22147 {
22148 ASSERT(open_error != 0);
22149 return open_error;
22150 }
22151
22152 824 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
22153 824 memset(extra_rules, 0, EXTRARULES_SIZE);
22154 824 unpack_qrs();
22155
22156
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 492 times.
824 if (!get_bit(skip_flags, skip_maps))
22157 492 Regions = {};
22158
22159
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 492 times.
824 if(do_clear_scripts)
22160 {
22161 492 zScript.clear();
22162 492 globalmap.clear();
22163 492 genericmap.clear();
22164 492 ffcmap.clear();
22165 492 itemmap.clear();
22166 492 npcmap.clear();
22167 492 ewpnmap.clear();
22168 492 lwpnmap.clear();
22169 492 playermap.clear();
22170 492 dmapmap.clear();
22171 492 screenmap.clear();
22172 492 itemspritemap.clear();
22173 492 comboscriptmap.clear();
22174 492 subscreenmap.clear();
22175
22176
2/2
✓ Branch 0 taken 251412 times.
✓ Branch 1 taken 492 times.
251904 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
22177 {
22178 251412 ffcmap[i].clear();
22179 251412 }
22180
22181 492 globalmap[0].slotname = "Slot 1:";
22182 492 globalmap[0].scriptname = "~Init";
22183 492 globalmap[0].update();
22184
22185
2/2
✓ Branch 0 taken 3444 times.
✓ Branch 1 taken 492 times.
3936 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
22186 {
22187 3444 globalmap[i].clear();
22188 3444 }
22189
22190
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
22191 {
22192 125460 itemmap[i].clear();
22193 125460 }
22194
22195 //new script types -- prevent carrying over to a quest that you load after reading them
22196 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
22197
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
22198 {
22199 125460 npcmap[i].clear();
22200 125460 }
22201
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22202 {
22203 125460 lwpnmap[i].clear();
22204 125460 }
22205
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22206 {
22207 125460 ewpnmap[i].clear();
22208 125460 }
22209
2/2
✓ Branch 0 taken 1968 times.
✓ Branch 1 taken 492 times.
2460 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
22210 {
22211 1968 playermap[i].clear();
22212 1968 }
22213
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
22214 {
22215 125460 dmapmap[i].clear();
22216 125460 }
22217
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
22218 {
22219 125460 screenmap[i].clear();
22220 125460 }
22221
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
22222 {
22223 125460 itemspritemap[i].clear();
22224 125460 }
22225
2/2
✓ Branch 0 taken 251412 times.
✓ Branch 1 taken 492 times.
251904 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
22226 {
22227 251412 comboscriptmap[i].clear();
22228 251412 }
22229
2/2
✓ Branch 0 taken 251412 times.
✓ Branch 1 taken 492 times.
251904 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22230 {
22231 251412 genericmap[i].clear();
22232 251412 }
22233
2/2
✓ Branch 0 taken 125460 times.
✓ Branch 1 taken 492 times.
125952 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22234 {
22235 125460 subscreenmap[i].clear();
22236 125460 }
22237
22238 492 reset_scripts();
22239 492 }
22240
22241 824 zquestheader tempheader{};
22242
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 tempheader.filename = filename;
22243
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 zinfo tempzi;
22244
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 tempzi.clear();
22245 824 load_tmp_zi = &tempzi;
22246
22247 char zinfofilename[2048];
22248
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 replace_extension(zinfofilename, filename, "zinfo", 2047);
22249 824 int32_t ret=0;
22250
22251 //header
22252
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 box_out("Reading Header...");
22253
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 ret=readheader(f, &tempheader, printmetadata);
22254
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
824 checkstatus(ret);
22255
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 box_out("okay.");
22256
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 box_eol();
22257
22258
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 614 times.
824 if(read_zinfo)
22259 {
22260
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 box_out("Reading ZInfo - ");
22261
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 box_out(read_ext_zinfo ? "External..." : "Internal...");
22262
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
210 if(read_ext_zinfo)
22263 {
22264
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22265
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22266
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22267
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22268 3 }
22269 else
22270 {
22271
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 ret=readzinfo(f, tempzi, tempheader);
22272
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
207 checkstatus(ret);
22273 }
22274
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 box_out("okay.");
22275
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 box_eol();
22276 210 }
22277
22278
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 24 times.
824 if(tempheader.zelda_version>=0x193)
22279 {
22280 dword section_id;
22281
22282 //section id
22283
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_mgetl(&section_id,f))
22284 {
22285 goto invalid;
22286 }
22287
22288 800 std::set<dword> seen_sections;
22289
22290
3/4
✓ Branch 0 taken 19469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18669 times.
✓ Branch 3 taken 800 times.
19469 while(!pack_feof(f))
22291 {
22292
2/4
✓ Branch 0 taken 18669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18669 times.
✗ Branch 3 not taken.
18669 if (seen_sections.contains(section_id))
22293 goto invalid;
22294
1/2
✓ Branch 0 taken 18669 times.
✗ Branch 1 not taken.
18669 seen_sections.insert(section_id);
22295
22296
3/4
✓ Branch 0 taken 18669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11718 times.
✓ Branch 3 taken 6951 times.
18669 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22297 {
22298
1/2
✓ Branch 0 taken 6951 times.
✗ Branch 1 not taken.
6951 if (retval == qe_cancel)
22299 6951 continue;
22300 checkstatus(retval);
22301 }
22302
22303
24/25
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 800 times.
✓ Branch 3 taken 800 times.
✓ Branch 4 taken 469 times.
✓ Branch 5 taken 410 times.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 469 times.
✓ Branch 8 taken 469 times.
✓ Branch 9 taken 469 times.
✓ Branch 10 taken 469 times.
✓ Branch 11 taken 469 times.
✓ Branch 12 taken 410 times.
✓ Branch 13 taken 410 times.
✓ Branch 14 taken 469 times.
✓ Branch 15 taken 469 times.
✓ Branch 16 taken 410 times.
✓ Branch 17 taken 410 times.
✓ Branch 18 taken 410 times.
✓ Branch 19 taken 410 times.
✓ Branch 20 taken 469 times.
✓ Branch 21 taken 469 times.
✓ Branch 22 taken 410 times.
✓ Branch 23 taken 410 times.
✗ Branch 24 not taken.
11718 switch(section_id)
22304 {
22305 case ID_RULES:
22306
22307 //rules
22308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22309 {
22310 box_out("found.");
22311 box_eol();
22312 catchup=false;
22313 }
22314
22315
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Rules...");
22316
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readrules(f, &tempheader);
22317
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22318
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22319
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22320 469 break;
22321
22322 case ID_STRINGS:
22323
22324 //strings
22325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22326 {
22327 box_out("found.");
22328 box_eol();
22329 catchup=false;
22330 }
22331
22332
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Strings...");
22333
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readstrings(f, &tempheader);
22334
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22335
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22336
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22337 469 break;
22338
22339 case ID_MISC:
22340
22341 //misc data
22342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(catchup)
22343 {
22344 box_out("found.");
22345 box_eol();
22346 catchup=false;
22347 }
22348
22349
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_out("Reading Misc. Data...");
22350
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 ret=readmisc(f, &tempheader, Misc);
22351
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
800 checkstatus(ret);
22352
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_out("okay.");
22353
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_eol();
22354 800 break;
22355
22356 case ID_TILES:
22357
22358 //tiles
22359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(catchup)
22360 {
22361 box_out("found.");
22362 box_eol();
22363 catchup=false;
22364 }
22365
22366
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_out("Reading Tiles...");
22367
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22368
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
800 checkstatus(ret);
22369
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_out("okay.");
22370
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_eol();
22371 800 break;
22372
22373 case ID_COMBOS:
22374
22375 //combos
22376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22377 {
22378 box_out("found.");
22379 box_eol();
22380 catchup=false;
22381 }
22382
22383
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Combos...");
22384
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22385 469 combosread=true;
22386
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22387
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22388
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22389 469 break;
22390
22391 case ID_COMBOALIASES:
22392
22393 //combo aliases
22394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22395 {
22396 box_out("found.");
22397 box_eol();
22398 catchup=false;
22399 }
22400
22401
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Combo Aliases...");
22402
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22403
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22404
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22405
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22406 410 break;
22407
22408 case ID_CSETS:
22409
22410 //color data
22411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(catchup)
22412 {
22413 box_out("found.");
22414 box_eol();
22415 catchup=false;
22416 }
22417
22418
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_out("Reading Color Data...");
22419
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22420
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
800 checkstatus(ret);
22421
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_out("okay.");
22422
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 box_eol();
22423 800 break;
22424
22425 case ID_MAPS:
22426
22427 //maps
22428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22429 {
22430 box_out("found.");
22431 box_eol();
22432 catchup=false;
22433 }
22434
22435
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Maps...");
22436
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readmaps(f, &tempheader);
22437 469 mapsread=true;
22438
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22439
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22440
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22441 469 break;
22442
22443 case ID_DMAPS:
22444
22445 //dmaps
22446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22447 {
22448 box_out("found.");
22449 box_eol();
22450 catchup=false;
22451 }
22452
22453
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading DMaps...");
22454
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22455
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22456
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22457
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22458 469 break;
22459
22460 case ID_DOORS:
22461
22462 //door combo sets
22463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22464 {
22465 box_out("found.");
22466 box_eol();
22467 catchup=false;
22468 }
22469
22470
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Doors...");
22471
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readdoorcombosets(f, &tempheader);
22472
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22473
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22474
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22475 469 break;
22476
22477 case ID_ITEMS:
22478
22479 //items
22480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22481 {
22482 box_out("found.");
22483 box_eol();
22484 catchup=false;
22485 }
22486
22487
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Items...");
22488
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22489
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22490
22491
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22492
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22493 469 break;
22494
22495 case ID_WEAPONS:
22496
22497 //weapons
22498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22499 {
22500 box_out("found.");
22501 box_eol();
22502 catchup=false;
22503 }
22504
22505
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Weapons...");
22506
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readweapons(f, &tempheader);
22507
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22508
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22509
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22510 469 break;
22511
22512 case ID_COLORS:
22513
22514 //misc. colors
22515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22516 {
22517 box_out("found.");
22518 box_eol();
22519 catchup=false;
22520 }
22521
22522
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Misc. Colors...");
22523
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readmisccolors(f, &tempheader, Misc);
22524
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22525
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22526
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22527 410 break;
22528
22529 case ID_ICONS:
22530
22531 //game icons
22532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22533 {
22534 box_out("found.");
22535 box_eol();
22536 catchup=false;
22537 }
22538
22539
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Game Icons...");
22540
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readgameicons(f, &tempheader, Misc);
22541
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22542
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22543
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22544 410 break;
22545
22546 case ID_INITDATA:
22547
22548 //initialization data
22549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22550 {
22551 box_out("found.");
22552 box_eol();
22553 catchup=false;
22554 }
22555
22556
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Init. Data...");
22557
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readinitdata(f, &tempheader);
22558
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22559
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22560
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22561
22562
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 if(!get_bit(skip_flags, skip_subscreens))
22563 {
22564
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 375 times.
469 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22565 {
22566
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22567
22568
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22569 {
22570 48128 int32_t type=DMaps[i].type&dmfTYPE;
22571
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22572 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22573 48128 }
22574 94 }
22575 469 }
22576
22577
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!get_bit(skip_flags, skip_sfx))
22578 {
22579 469 setupsfx();
22580 469 }
22581
22582
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
469 if(!get_bit(skip_flags, skip_itemdropsets))
22583 {
22584
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 init_item_drop_sets();
22585 469 }
22586
22587
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 if(!get_bit(skip_flags, skip_favorites))
22588 {
22589 469 init_favorites();
22590 469 }
22591
22592 469 break;
22593
22594 case ID_GUYS:
22595
22596 //guys
22597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22598 {
22599 box_out("found.");
22600 box_eol();
22601 catchup=false;
22602 }
22603
22604
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Custom Guy Data...");
22605
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readguys(f, &tempheader);
22606
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22607
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22608
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22609 469 break;
22610
22611 case ID_HEROSPRITES:
22612
22613 //hero sprites
22614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22615 {
22616 box_out("found.");
22617 box_eol();
22618 catchup=false;
22619 }
22620
22621
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Custom Hero Sprite Data...");
22622
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readherosprites(f, &tempheader);
22623
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22624
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22625
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22626 410 break;
22627
22628 case ID_SUBSCREEN:
22629
22630 //custom subscreens
22631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22632 {
22633 box_out("found.");
22634 box_eol();
22635 catchup=false;
22636 }
22637
22638
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Custom Subscreen Data...");
22639
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readsubscreens(f);
22640
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22641
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22642
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22643 410 break;
22644
22645 case ID_FFSCRIPT:
22646
22647 //Freeform combo scripts
22648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22649 {
22650 box_out("found.");
22651 box_eol();
22652 catchup=false;
22653 }
22654
22655
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading FF Script Data...");
22656
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readffscript(f, &tempheader);
22657
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22658
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22659
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22660 410 break;
22661
22662 case ID_SFX:
22663
22664 //SFX data
22665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22666 {
22667 box_out("found.");
22668 box_eol();
22669 catchup=false;
22670 }
22671
22672
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading SFX Data...");
22673
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readsfx(f, &tempheader);
22674
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22675
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22676
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22677 410 break;
22678
22679 case ID_MIDIS:
22680
22681 //midis
22682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22683 {
22684 box_out("found.");
22685 box_eol();
22686 catchup=false;
22687 }
22688
22689
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading MIDIs...");
22690
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readmidis(f, &tempheader, tunes);
22691
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22692
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22693
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22694 469 break;
22695
22696 case ID_CHEATS:
22697
22698 //cheat codes
22699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(catchup)
22700 {
22701 box_out("found.");
22702 box_eol();
22703 catchup=false;
22704 }
22705
22706
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("Reading Cheat Codes...");
22707
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ret=readcheatcodes(f, &tempheader);
22708
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
469 checkstatus(ret);
22709
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_out("okay.");
22710
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 box_eol();
22711 469 break;
22712
22713 case ID_ITEMDROPSETS:
22714
22715 //item drop sets
22716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22717 {
22718 box_out("found.");
22719 box_eol();
22720 catchup=false;
22721 }
22722
22723
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Item Drop Sets...");
22724
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readitemdropsets(f, tempheader.zelda_version);
22725
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22726
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22727
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22728 410 break;
22729
22730 case ID_FAVORITES:
22731
22732 //favorite combos and combo aliases
22733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if(catchup)
22734 {
22735 box_out("found.");
22736 box_eol();
22737 catchup=false;
22738 }
22739
22740
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("Reading Favorite Combos...");
22741
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 ret=readfavorites(f, tempheader.zelda_version);
22742
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
410 checkstatus(ret);
22743
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_out("okay.");
22744
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 box_eol();
22745 410 break;
22746
22747 default:
22748 if(!catchup)
22749 {
22750 box_out("Bad token! Searching...");
22751 box_eol();
22752 }
22753
22754 catchup=true;
22755 break;
22756 }
22757
22758
22759
1/2
✓ Branch 0 taken 11718 times.
✗ Branch 1 not taken.
11718 if(catchup)
22760 {
22761 //section id
22762 section_id=(section_id<<8);
22763
22764 if(!p_getc(&tempbyte,f))
22765 {
22766 goto invalid;
22767 }
22768
22769 section_id+=tempbyte;
22770 }
22771
22772 else
22773 {
22774 //section id
22775
3/4
✓ Branch 0 taken 11718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11249 times.
✓ Branch 3 taken 469 times.
11718 if(!pack_feof(f))
22776 {
22777
2/4
✓ Branch 0 taken 11249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11249 times.
✗ Branch 3 not taken.
11249 if(!p_mgetl(&section_id,f))
22778 {
22779 goto invalid;
22780 }
22781 11249 }
22782 }
22783 }
22784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 }
22785 else
22786 {
22787
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22788
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22789
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22790
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22791
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22792
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22793
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22794
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22795
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22796
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22797
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22798
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22799
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22800
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "MIDIs", ID_MIDIS, [&](){ return readmidis(f, &tempheader, tunes); }},
22801
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22802
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22803
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22804
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22805 };
22806
22807 24 legacy_skip_flags = skip_flags;
22808
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22809 {
22810
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22811
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22812
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22813 {
22814 // Nothing to read.
22815
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22816 1 continue;
22817
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22818 1 continue;
22819
22820 // Haven't looked at how to skip these, because we don't need to currently: the only
22821 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22822
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22823 1 continue;
22824
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22825 1 continue;
22826
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22827 1 continue;
22828
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22829 1 continue;
22830
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22831 1 continue;
22832 9 }
22833
22834 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22835 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22836 // read all the sections even if requested to skip some.
22837 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22838 // {
22839 // if (retval == qe_cancel)
22840 // continue;
22841 // checkstatus(retval);
22842 // }
22843
22844
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22845
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22846
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22847
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22848
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22849 }
22850 24 legacy_skip_flags = nullptr;
22851
22852
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22853 {
22854
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22855
22856
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22857 {
22858 11776 int32_t type=DMaps[i].type&dmfTYPE;
22859
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22860 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22861 11776 }
22862 23 }
22863
22864
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22865
22866
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22867 23 setupsfx();
22868
22869
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22870 23 init_favorites();
22871
22872
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22873
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22874
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22875
22876
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 init_spritelists();
22877
22878 // check data
22879
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(f)
22880 {
22881
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 pack_fclose(f);
22882 824 }
22883
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 clear_quest_tmpfile();
22884
22885
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!oldquest)
22886 {
22887
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if(exists(tmpfilename))
22888 {
22889 delete_file(tmpfilename);
22890 }
22891 824 }
22892
22893
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
824 if(fixffcs && combosread && mapsread)
22894 {
22895 for(int32_t i=0; i<map_count; i++)
22896 {
22897 for(int32_t j=0; j<MAPSCRS; j++)
22898 {
22899 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22900 for(int32_t m=0; m<c; m++)
22901 {
22902 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22903 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22904 }
22905 }
22906 }
22907 }
22908
22909
3/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 332 times.
824 if (!get_bit(skip_flags, skip_rules))
22910 {
22911
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22912
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22913
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 418 times.
492 if (should_hide)
22914
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22915
22916
3/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 165 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 327 times.
492 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22917 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22918 492 }
22919
22920
7/10
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 761 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
824 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22921 {
22922
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 set_qr(qr_CONTFULL_DEP, 0);
22923
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22924 62 zinit.cont_heart=100;
22925 62 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22926 62 }
22927
22928
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 box_out("Done.");
22929
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 box_eol();
22930
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 box_end(false);
22931
22932
3/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 493 times.
✓ Branch 3 taken 331 times.
824 if(!get_bit(skip_flags, skip_header))
22933 {
22934
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 *Header = tempheader;
22935 493 }
22936
3/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 332 times.
824 if(!get_bit(skip_flags, skip_zinfo))
22937 {
22938
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 ZI.copyFrom(tempzi);
22939 492 }
22940
22941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(loading_tileset_flags & TILESET_CLEARMAPS)
22942 {
22943 TheMaps.clear();
22944 TheMaps.resize(MAPSCRS*1);
22945 map_count = 1;
22946 map_infos.clear();
22947 map_infos.resize(1);
22948 }
22949
22950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(loading_tileset_flags & TILESET_CLEARHEADER)
22951 {
22952 memset(Header->password, 0, sizeof(Header->password));
22953 memset(Header->minver, 0, sizeof(Header->minver));
22954 memset(Header->title, 0, sizeof(Header->title));
22955 memset(Header->author, 0, sizeof(Header->author));
22956 memset(Header->version, 0, sizeof(Header->version));
22957 Header->use_keyfile = 0;
22958 Header->dirty_password = false;
22959 cvs_MD5Context ctx;
22960 cvs_MD5Init(&ctx);
22961 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22962 cvs_MD5Final(Header->pwd_hash, &ctx);
22963 }
22964
22965
3/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 332 times.
824 if (!get_bit(skip_flags, skip_maps))
22966 {
22967 // Not needed, so release its memory.
22968
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 old_combo_pages = {};
22969 492 }
22970
22971
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 492 times.
824 if (skipping_any)
22972
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 restore_prev_qstload_global_state();
22973
22974 824 return qe_OK;
22975
22976 invalid:
22977 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22978 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22979 box_out("error.");
22980 box_eol();
22981 box_end(true);
22982
22983 pack_fclose(f);
22984
22985 if(!oldquest)
22986 {
22987 if(exists(tmpfilename))
22988 {
22989 delete_file(tmpfilename);
22990 }
22991 }
22992
22993 restore_prev_qstload_global_state();
22994
22995 return qe_invalid;
22996
22997 824 }
22998
22999 331 std::string get_last_loaded_qstpath()
23000 {
23001 331 return last_loaded_qstpath;
23002 }
23003
23004 824 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
23005 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
23006 bool report, byte qst_num, dword tilesetflags)
23007 {
23008 824 loading_tileset_flags = tilesetflags;
23009 824 const char* basename = get_filename(filename);
23010 824 zapp_reporting_add_breadcrumb("load_quest", basename);
23011 824 zapp_reporting_set_tag("qst.filename", basename);
23012
23013 824 last_loaded_qstpath = filename;
23014 824 loading_qst_name = filename;
23015 824 loading_qst_num = qst_num;
23016 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
23017 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
23018
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if (!is_ci())
23019 loadquest_report = report;
23020
23021 824 auto start = std::chrono::steady_clock::now();
23022 824 zprint2("Loading qst: %s\n", filename);
23023 824 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
23024 824 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
23025 824 zprint2("Time to load qst: %d ms\n", load_ms);
23026
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if (ret)
23027 zprint2("Error: %s\n", qst_error[ret]);
23028
23029
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(show_progress)
23030 {
23031 if(ret)
23032 {
23033 box_out("-- Error loading quest file! --");
23034 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
23035 box_end(true);
23036 }
23037 else box_end(false);
23038 }
23039
23040 824 load_tmp_zi = NULL;
23041 824 loading_qst_name = NULL;
23042 824 loadquest_report = false;
23043 824 loading_qst_num = 0;
23044
23045 824 zapp_reporting_set_tag("qst.author", Header->author);
23046 824 zapp_reporting_set_tag("qst.title", Header->title);
23047 824 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
23048
23049 824 return ret;
23050 }
23051